dongtuoao7987 2018-03-19 13:43
浏览 66
已采纳

Soap请求验证php

Hi Guys I am trying to make a request and get a response for authenticating my SOAP request.

I tried many different options but this one was the only one which gave me response(even an error 404).

This is my code

$client = new SOAPClient('http://devapi.stellatravelgateway.stellatravelservices.co.uk/DirectoryService.svc?singleWsdl',
 array(
    'location' => 'http://stellatravelgateway.stellatravelservices.co.uk/DirectoryService/IDirectoryService/Authenticate',
    'trace' => 1,
    'style' => SOAP_RPC,
    'use' => SOAP_ENCODED,
  )
 );

$request = array(
  "BranchCode" => "xxx",
  "UserName" => "xxx",
  "Password" => "xxx",
  "Application" => "xxx",
  "Client" => "x",
  "BranchID" => 0
);

$result = array();

try {
    $result = $client->__soapCall('Authenticate', $request);
} catch (SoapFault $e) {
    echo "SOAP Fault: ".$e->getMessage()."<br />
";
}

 echo "<pre>";
 echo htmlspecialchars($client->__getLastRequestHeaders())."
";
 echo htmlspecialchars($client->__getLastRequest())."
";
 echo "Response:
".htmlspecialchars($client->__getLastResponseHeaders())."
";
 echo htmlspecialchars($client->__getLastResponse())."
";
 echo "</pre>"; 

 var_dump($result);

What am i doing wrong? I dont get any response I get thsi

POST /DirectoryService/IDirectoryService/Authenticate HTTP/1.1
Host: stellatravelgateway.stellatravelservices.co.uk
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.5.38
Content-Type: text/xml; charset=utf-8
SOAPAction:"http://stellatravelgateway.stellatravelservices.co.uk/DirectoryService/IDirectoryService/Authenticate"
Content-Length: 367


<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://stellatravelgateway.stellatravelservices.co.uk/DirectoryService"><SOAP-ENV:Body><ns1:Authenticate/><param1>xxx</param1><param2>xxx</param2><param3>xxx</param3><param4>x</param4><param5>0</param5></SOAP-ENV:Body></SOAP-ENV:Envelope>

Response:
HTTP/1.1 404 Not Found // Here
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Mon, 19 Mar 2018 13:34:51 GMT
Connection: close
Content-Length: 1245

This is the exact request I need to send :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dir="http://stellatravelgateway.stellatravelservices.co.uk/DirectoryService">
    <soapenv:Header/>
      <soapenv:Body>
         <dir:Authenticate>
           <dir:authenticateRequest BranchCode="xxx" UserName="xxx" Password="xxx" Application="xxx" Client="xxx">
           <dir:BranchID>xxx</dir:BranchID>
          </dir:authenticateRequest>
        </dir:Authenticate>
      </soapenv:Body>
   </soapenv:Envelope>

EDIT: This is what I get on raw from SoapUI:

POST http://stellatravelgateway.stellatravelservices.co.uk/AirService HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "http://stellatravelgateway.stellatravelservices.co.uk/DirectoryService/IDirectoryService/Authenticate"
Content-Length: 602
Host: stellatravelgateway.stellatravelservices.co.uk
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

Please guys any help would be great, any feedback! Thank you in advance.

  • 写回答

2条回答 默认 最新

  • douchuoliu4422 2018-03-19 14:02
    关注

    Remove the 'location' param from options, and call the Authenticate() function like this:

    try {
        $result = $client->Authenticate(array('authenticateRequest'=>$request));
    } catch (SoapFault $e) {
    

    result:

    POST /DirectoryService.svc HTTP/1.1
    Host: devapi.stellatravelgateway.stellatravelservices.co.uk
    Connection: Keep-Alive
    User-Agent: PHP-SOAP/5.6.32
    Content-Type: text/xml; charset=utf-8
    SOAPAction: "http://stellatravelgateway.stellatravelservices.co.uk/DirectoryService/IDirectoryService/Authenticate"
    Content-Length: 446
    
    
    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://stellatravelgateway.stellatravelservices.co.uk/DirectoryService"><SOAP-ENV:Body><ns1:Authenticate><ns1:authenticateRequest BranchCode="xxx" UserName="xxx" Password="xxx" Application="xxx" Client="x"><ns1:BranchID>0</ns1:BranchID></ns1:authenticateRequest></ns1:Authenticate></SOAP-ENV:Body></SOAP-ENV:Envelope>
    
    Response:
    HTTP/1.1 200 OK
    Content-Type: text/xml; charset=utf-8
    Server: Microsoft-IIS/8.5
    X-Powered-By: ASP.NET
    Date: Mon, 19 Mar 2018 14:06:43 GMT
    Connection: close
    Content-Length: 522
    
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><AuthenticateResponse xmlns="http://stellatravelgateway.stellatravelservices.co.uk/DirectoryService"><AuthenticateResult Success="false" Narrative="Invalid details. Please check request. " CanBeOpenedInEditMode="false" ErrorCode="200002"><Token xsi:nil="true"/><Expiry xsi:nil="true"/></AuthenticateResult></AuthenticateResponse></s:Body></s:Envelope>
    object(stdClass)#2 (1) {
      ["AuthenticateResult"]=>
      object(stdClass)#3 (6) {
        ["Success"]=>
        bool(false)
        ["Narrative"]=>
        string(39) "Invalid details. Please check request. "
        ["CanBeOpenedInEditMode"]=>
        bool(false)
        ["ErrorCode"]=>
        int(200002)
        ["Token"]=>
        NULL
        ["Expiry"]=>
        NULL
      }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求指导ADS低噪放设计
  • ¥15 CARSIM前车变道设置
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存