dpa89292 2015-06-29 11:45
浏览 49
已采纳

使用包含Document / literal的NuSoap PHP调用SOAP客户端

Im trying to make a SOAP call, but have to many problems.

Im using this:

$client = new nusoap_client('http://odigo.xxx.com/xxx/servlet/services/WebCallBack?wsdl'); 
$client -> setEndpoint('https://odigo2.xxx.com/xxx/servlet/services/WebCallBack.WebCallBackHttpSoap11Endpoint/'); 

$client->soap_defencoding = 'UTF-8';

error message:
$error = $client->getError();

if ($error) {
die("client construction error: {$error}
");
}

$param = array('skillKeyWord' => 'yyy',
             'phoneNumber' => '999999999',
             'user' => 'XXX',
             'password' => 'XXX',
            );
$result = $client->call('saveCallBack', array('parameters' => $param), '', '', false, true);

The IT department of the Client tell me, the request are wrong, because: "need to use Document/literal wrapped, not encoded" and "parameters are wrong encapsulated"

The correct call they send to us, is this example:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <saveCallBack xmlns ="http://odigo.xxx.com/2009/09/21/webcallback.xsd" xmlns:ns2="http://webcallback.ws.bean.model.odigo.xxx.com/xsd" xmlns:ns3="http://administration.bean.model.odigo.xxx.com/xsd">
         <webCallBack>
            <ns2:date>0</ns2:date>
            <ns2:phoneNumber>9999999</ns2:phoneNumber>
            <ns2:skillKeyWord>yyy</ns2:skillKeyWord>
         </webCallBack>
         <user>
            <ns3:login>XXX</ns3:login>
            <ns3:password>XXX</ns3:password>
         </user>
      </saveCallBack>
   </soap:Body>
</soap:Envelope>

I dont know how i can send this format call using nusoap, or using this XML to make a call using nusoap.

Any help its appreciated.

  • 写回答

1条回答 默认 最新

  • dongwei3712 2015-06-29 12:05
    关注

    Try using CURL. Code is shown below:

    $soap_body   = '<?xml version="1.0" encoding="utf-8"?>'.
                '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'.
                    '<soap:Body>'.
                        '<saveCallBack xmlns ="http://odigo.xxx.com/2009/09/21/webcallback.xsd" xmlns:ns2="http://webcallback.ws.bean.model.odigo.xxx.com/xsd" xmlns:ns3="http://administration.bean.model.odigo.xxx.com/xsd">'.
                            '<webCallBack>'.
                                '<ns2:date>0</ns2:date>'.
                                '<ns2:phoneNumber>9999999</ns2:phoneNumber>'.
                                '<ns2:skillKeyWord>yyy</ns2:skillKeyWord>'.
                            '</webCallBack>'.
                            '<user>'.
                                '<ns3:login>XXX</ns3:login>'.
                                '<ns3:password>XXX</ns3:password>'.
                            '</user>'.
                        '</saveCallBack>'.
                    '</soap:Body>'.
                '</soap:Envelope>'; 
    
    $headers = array
    ( 
       'Content-Type: text/xml; charset="utf-8"', 
       'Content-Length: '. strlen($soap_body), 
       'Accept: text/xml', 
       'Cache-Control: no-cache', 
       'Pragma: no-cache'
    );
    
    $ch = curl_init(); 
    
    curl_setopt($ch, CURLOPT_URL, 'http://odigo.xxx.com/xxx/servlet/services/WebCallBack?wsdl'); 
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $soap_body); 
    
    $result = curl_exec($ch);
    //do something useful with $result variable
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容