我对这个问题有一个补充:
请求如下:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns="...">
<s:Body>
<Search>
<login>
<Wholesaler>...</Wholesaler>
<Username>...</Username>
<Password>...</Password>
</login>
<itemRequests>
<ItemRequest>
<ArticleId>int</ArticleId>
<SupplierId>int</SupplierId>
<QuantityRequested>int</QuantityRequested>
</ItemRequest>
</itemRequests>
</Search>
</s:Body>
</s:Envelope>
我需要发送两个 SoapHeaders:
Content-Type: text/xml; charset=utf-8
SOAPAction: URI
我确实知道服务提供商和操作标识符。
如果我有以下变量
$service
$action
$request
$header
如何在 PHP 中发送请求?我试过了
$client = new SoapClient($service);
$result = $client->__doRequest($request, $service, $action);
但我似乎没有收到回复...
这就是响应应该是这样的:
Date: Thu, 09 Aug 2012 08:01:40 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Content-Length: 408
Cache-Control: private
Content-Type: text/xml; charset=utf-8
<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">
<SearchResponse xmlns="...">
<SearchResult>
<Wholesaler>...</Wholesaler>
<Username>...</Username>
<Error>false</Error>
<DateTime>2012-08-09T10:01:40.39125+02:00</DateTime>
<ItemResults />
</SearchResult>
</SearchResponse>
</s:Body>
</s:Envelope>
当我做一个简单的 echo $result 时,屏幕保持白色,并且在代码中没有可见的 XML。