PHP调用WSDL接口并与之通信有问 phpwsdl 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 先看看都有什么$client = new SoapClient('http://183.63.194.18:2000/TTS/Services/CodeService.svc?wsdl');//print_r($client);echo '<xmp>';echo "提供的方法\n";print_r( $client->__getFunctions ()); echo "相关的数据结构\n";print_r($client->__getTypes () ); echo '</xmp>';print_r($client->saveInter(array())); 由 GetCodeBatchesResponse GetCodeBatches(GetCodeBatches $parameters) 可知,需要传递一个 GetCodeBatches 结构的参数struct GetCodeBatches { string codeId;}$client->GetCodeBatches(array( 'codeId' => ?));具体值该是多少,只有你知道 __getFunctions () 这个可以得到所有动作的列表还有你是如何链接的会报错??贴出代码 报错了,具体报错如下:我的代码是这样的:<?php header("Content-type:text/xml;charset=utf-8"); $client = new SoapClient('http://183.63.194.18:2000/TTS/Services/CodeService.svc?wsdl'); /*//print_r($client); echo '<xmp>'; echo "提供的方法\n"; print_r( $client->__getFunctions ()); echo "相关的数据结构\n"; print_r($client->__getTypes () ); echo '</xmp>'; print_r($client->saveInter(array()));*/ $parameters = "208x6XBJ140000080"; $client->GetCodeBatches(array( 'codeId' => $parameters));?>如果我不加那个header的话,报错就会变成这样: 设置 SoapClient 的第二个参数为array( 'trace' => true, 'cache_wsdl' => WSDL_CACHE_NONE, 'soap_version' => SOAP_1_2,)错误信息为Fatal error: Uncaught SoapFault exception: [s:Sender] The SOAP action specified on the message, '', does not match the HTTP SOAP Action, 'http://tempuri.org/ICodeService/GetCodeBatches'.意思是说不符合 http://tempuri.org/ICodeService/GetCodeBatches 的约束,如何处理就不知道了 我刚刚设置了soap的版本也出现这个报错,我看到有的资料说需要从接口那边下载一个什么代理类,什么的,表示各种看不懂,谷歌也没查出什么问题. 在谷歌查了,查了一下跟我同样问题的提问,最后代码改成这样了<?php $client = new SoapClient('http://183.63.194.18:2000/TTS/Services/CodeService.svc?wsdl',array('soap_version' => SOAP_1_2,"trace" => "1")); $actionHeader = new SoapHeader('http://www.w3.org/2005/08/addressing', 'Action', 'http://tempuri.org/ICodeService/GetCodeBatches'); $client->__setSoapHeaders($actionHeader);$parameters = "208x6XBJ140000080";$client->__call('GetCodeBatches',array( 'codeId' => $parameters));?>现在之前的报错没有了,但是报其他的错误 thinkphp循环输出怎么写 如何获得网页里的连接地址 session_id经常变,导致无法正常使用session。世界太难题! PHP 读取绝对地址里内容 怎么写? mysql用什么语句让指针指向下一个? 如何在頁面上隱藏圖片(菜鳥問!希望高手多多指點!) 求自动跳转到另一个页面的代码! exit()问题 [请教]如何在php中实现类似include()的功能 能执行PHP,但不能执行PHP3 优先级 这段代码中echo怎么不执行呢,高手给支个招
//print_r($client);
echo '<xmp>';
echo "提供的方法\n";
print_r( $client->__getFunctions ());
echo "相关的数据结构\n";
print_r($client->__getTypes () );
echo '</xmp>';
print_r($client->saveInter(array()));
struct GetCodeBatches {
string codeId;
}$client->GetCodeBatches(array( 'codeId' => ?));
具体值该是多少,只有你知道
<?php
header("Content-type:text/xml;charset=utf-8");
$client = new SoapClient('http://183.63.194.18:2000/TTS/Services/CodeService.svc?wsdl');
/*//print_r($client);
echo '<xmp>';
echo "提供的方法\n";
print_r( $client->__getFunctions ());
echo "相关的数据结构\n";
print_r($client->__getTypes () );
echo '</xmp>';
print_r($client->saveInter(array()));*/
$parameters = "208x6XBJ140000080";
$client->GetCodeBatches(array( 'codeId' => $parameters));
?>
如果我不加那个header的话,报错就会变成这样:
array(
'trace' => true,
'cache_wsdl' => WSDL_CACHE_NONE,
'soap_version' => SOAP_1_2,
)
错误信息为
Fatal error: Uncaught SoapFault exception: [s:Sender] The SOAP action specified on the message, '', does not match the HTTP SOAP Action, 'http://tempuri.org/ICodeService/GetCodeBatches'.
意思是说不符合 http://tempuri.org/ICodeService/GetCodeBatches 的约束,如何处理就不知道了
<?php
$client = new SoapClient('http://183.63.194.18:2000/TTS/Services/CodeService.svc?wsdl',array('soap_version' => SOAP_1_2,"trace" => "1"));
$actionHeader = new SoapHeader('http://www.w3.org/2005/08/addressing',
'Action',
'http://tempuri.org/ICodeService/GetCodeBatches');
$client->__setSoapHeaders($actionHeader);
$parameters = "208x6XBJ140000080";
$client->__call('GetCodeBatches',array( 'codeId' => $parameters));
?>
现在之前的报错没有了,但是报其他的错误