试图将XML SOAP请求转换为PHP。这是我第一次编写SOAP请求。我熟悉PHP,但没有运气。这是我必须复制的XML请求:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:cap="http://services.urbanscience.com/captureservice" xmlns:data="http://www.urbanscience.com/els/orchestration/data">
<soap:Header>
<cap:SecurityIdentity>
<data:ApplicationId>1</data:ApplicationId>
<data:ClientId>1</data:ClientId>
<data:UserId>7</data:UserId>
</cap:SecurityIdentity>
<wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">http://services.urbanscience.com/captureservice/ICaptureService/DispositionRequest</wsa:Action>
<cap:ApplicationId>1</cap:ApplicationId>
<cap:ClientId>1</cap:ClientId>
<cap:UserId>7</cap:UserId>
</soap:Header>
<soap:Body>
<cap:CaptureRequest>
<cap:RawXml>
<ArrayOfDispositionActivity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DispositionActivity>
<!--Comes from DocumentId in the delivered lead -->
<UsaiId>165</UsaiId>
<!--Can be any id this is not validated by Urban Science-->
<LmsId>1946</LmsId>
<ReceivedDateTime>2015-03-16T10:59:13.5399397-04:00</ReceivedDateTime>
<ActivityDateTime>2015-03-16T11:34:37.0015824-04:00</ActivityDateTime>
<!--Predefined values that come from the C4 spec document-->
<ActivityType>Called Customer</ActivityType>
<!--Can be any username, this is not validated by UrbanScience-->
<UserName>Alex</UserName>
<LmsSource>HASCO</LmsSource>
</DispositionActivity>
</ArrayOfDispositionActivity>
</cap:RawXml>
</cap:CaptureRequest>
</soap:Body>
</soap:Envelope>
这是我到目前为止所做的,但我一直收到这个错误:
未捕获的SoapFault异常:[HTTP]错误获取http标头
我的PHP代码:
$soapClient = new SoapClient("https://braunabilityels.usaitechdev.com/C4CaptureService/services/captureservice.v1.soap.svc?singleWSDL");
$user_param = array (
'ApplicationId' => "1",
'ClientId' => "1",
'UserId' => "7"
);
$header_param = array (
'SecurityIdentity' => $user_param,
'ApplicationId' => "1",
'ClientId' => "1",
'UserId' => "7"
);
$header = new SoapHeader('http://services.urbanscience.com/captureservice','Auth',$header_param,false);
$soapClient->__setSoapHeaders($header);
$data_param = array (
'UsaiId' => "165",
'LmsId' => "1946",
'ReceivedDateTime' => "2015-03-16T10:59:13.5399397-04:00",
'ActivityDateTime' => "2015-03-16T11:34:37.0015824-04:00",
'ActivityType' => "Called Customer",
'UserName' => "Alex",
'LmsSource' => "HASCO"
);
$disposition_param = array (
'DispositionActivity' => $data_param,
);
$xml_param = array (
'RawXml' => $disposition_param,
);
$capturereq_param = array (
'CaptureRequest' => $xml_param,
);
print_r($soapClient->__soapCall("DispositionRequest",array($capturereq_param)));
print "<pre>\n";
print "<br />\n Request : ".htmlspecialchars($soapClient->__getLastRequest());
print "<br />\n Response: ".htmlspecialchars($soapClient->__getLastResponse());
print "</pre>";
我已经通过几种不同的方式完成了工作,但最终我的PHP日志中始终遇到了Fetching http headers错误。我已成功测试其他SOAP服务,所以我的想法是它与主请求服务下有多个请求的请求有关,而且我没有正确传递信息。我找不到任何看起来像这样的例子。
我的PHP版本是5.4.24 SOAP应用程序是1.2