我正在尝试使用SOAP连接到API服务器,我已经能够发出并查看我的请求,但是它一直返回错误“ SOAP错误:服务器无法处理请求。---> MaskRequestInfo args( 0)不是字符串类型“ 我是SOAP的新手,我正拼命尝试了解它的来龙去脉,而我这样做的时候,我只需要获取此API。它需要XML中带有凭据的标头(在提供的示例代码中用“ XXX”代替。)对此有任何见识,将不胜感激!
<?php
$client = new SoapClient('https://beta.triseptapi.com/11.0/vax.asmx?WSDL',
array(
'location' => 'https://beta.triseptapi.com/11.0/vax.asmx',
'trace' => 1,)
);
$request=
"<VAXXML xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns='http://Function_URL'>
<Header AgencyNumber='xxxx' Contact='xxxx' Login='xxxx' Password='xxxx'
Vendor='xxx' Site='xxx' DynamicPackageID='xxx' />
<Request>
<Content Destination='LAS' />
<Content Destination='MCO' />
</Request>
</VAXXML>";
$result = array();
$params = array("length" => "1", "string" => $request);
try {
$result = $client->__soapCall('HotelListRequest', $params);
}
catch (SoapFault $e)
{
echo "SOAP Fault: ".$e->getMessage()."<br />\n";
}
echo "<pre>";
echo htmlspecialchars($client->__getLastRequestHeaders())."\n";
echo htmlspecialchars($client->__getLastRequest())."\n";
echo "Response:\n".htmlspecialchars($client->__getLastResponseHeaders())."\n";
echo htmlspecialchars($client->__getLastResponse())."\n";
echo "</pre>";
var_dump($result);?>
sends to the server:
POST /11.0/vax.asmx HTTP/1.1
Host: beta.triseptapi.com
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.6.35
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://www.triseptsolutions.com/VAXXMLPortal110/VAX/HotelListRequest"
Content-Length: 589
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.triseptsolutions.com/VAXXMLPortal110/VAX"><SOAP-ENV:Body><ns1:HotelListRequest/><param1><Header AgencyNumber='xxx' Contact='xxx' Login='xxx' Password='xxx' Vendor='APV' Site='xxx' DynamicPackageID='xxx' />
<Request>
<Content Destination='LAS' />
<Content Destination='MCO' />
</Request></param1></SOAP-ENV:Body></SOAP-ENV:Envelope>
server returns:
Response:
HTTP/1.1 500 Internal Server Error
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 11 Feb 2019 20:00:14 GMT
Content-Length: 433
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Server was unable to process request. ---> MaskRequestInfo args(0) is not of type String</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
这是wsdl函数:
POST /11.0/vax.asmx HTTP/1.1
Host: beta.triseptapi.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.triseptsolutions.com/VAXXMLPortal110/VAX/HotelListRequest"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HotelListRequest xmlns="http://www.triseptsolutions.com/VAXXMLPortal110/VAX">
<requestXml>string</requestXml>
</HotelListRequest>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HotelListRequestResponse xmlns="http://www.triseptsolutions.com/VAXXMLPortal110/VAX">
<HotelListRequestResult>string</HotelListRequestResult>
</HotelListRequestResponse>
</soap:Body>
</soap:Envelope>
SOAP 1.2
The following is a sample SOAP 1.2 request and response. The placeholders shown need to be replaced with actual values.
POST /11.0/vax.asmx HTTP/1.1
Host: beta.triseptapi.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<HotelListRequest xmlns="http://www.triseptsolutions.com/VAXXMLPortal110/VAX">
<requestXml>string</requestXml>
</HotelListRequest>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<HotelListRequestResponse xmlns="http://www.triseptsolutions.com/VAXXMLPortal110/VAX">
<HotelListRequestResult>string</HotelListRequestResult>
</HotelListRequestResponse>
</soap12:Body>
该请求应如下所示:
<HotelListRequest xmlns="http://www.triseptsolutions.com/VAXXMLPortal110/VAX">
<requestXml>
<VAXXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.triseptsolutions.com/HotelList/Request/11.0">
<Header AgencyNumber="xxxx" Contact="XXXX" Login="XXXXXX" Password="XXXXX" Vendor="xxx" Site="VAXXML" DynamicPackageId="xxxx" />
<Request>
<Content Destination="LAS" />
<Content Destination="MCO" />
</Request>
</VAXXML>
</requestXml>
</HotelListRequest>