SoapClient与SoapServer的连接

ilh*_*ctn 1 php soap soap-client

我需要从php连接到SOAP服务器,我阅读了很多文档,示例和教程,但我仍然无法对我的服务器进行身份验证.我完成了以下工作:

 $agencyNumber = 7818619810;
    $fullTransmission = false;
    //$context = array('header' => 'Content-type: application/soap+xml; charset=utf-8');
    $params = array( 'agencyNumber'     => 7818619810, 'fullTransmission' => 0/*,$context*/);

    $client = new SoapClient("http://link/to/server?wsdl");
   $test =  $client->__getFunctions();
    var_dump($test );// returns the functions my supplier provides, as well __getTypes() gives a bunch of variable arrays ect..
    $response = $client->__soapCall('GetTransmissionTicket',array($params) );//line 16 which is mentioned on error print
    var_dump($response);
Run Code Online (Sandbox Code Playgroud)

即使我设置$context,当我尝试运行时,我得到以下错误:

致命错误:未捕获的SoapFault异常:[HTTP]无法处理消息,因为内容类型为'text/xml; charset = utf-8'不是预期的类型'application/soap + xml; 字符集= UTF-8' .在C:\ xampp\htdocs\xml\inc\_ connection_test.php:16堆栈跟踪:#0 [内部函数]:SoapClient-> __doRequest('http:// interfac ...','..//my- provider ...',1,0)#1 C:.. path..test.php(16):SoapClient - > __ soapCall('GetTransmission ...',Array)#2 {main}抛出C:.第16行的.path..test.php

我试图调用的远程方法被调用GetTransmissionTicket,它接受两个参数,(int)agencyNumber并且fullTransmission(bool)..

我想强调的是,有很多的线程就这一议题,其中一些是非常接近我的问题(1,2,3等..),但我真的无法解决问题.请亲自动手..亲切的问候..

udg*_*tel 10

尝试 $params = array( 'agencyNumber' => 7818619810, 'fullTransmission' => false);

代替 $params = array( 'agencyNumber' => 7818619810, 'fullTransmission' => 0);

要么

使用 $client = new SoapClient("http://link/to/server?wsdl", array('soap_version' => SOAP_1_1));

因为 application/soap+xml是使用SOAP 1.2时传递的内容类型,text/xml与SOAP 1.1一起使用,

参考: 如何更改内容类型的请求?