PHP中带有标头的复杂SOAP请求
正在尝试将XML SOAP请求转换为PHP。这是我第一次编写SOAP请求。我熟悉PHP,但运气不好。以下是我必须复制的XML请求:PHP中带有标头的复杂SOAP请求,php,xml,web-services,soap,wsdl,Php,Xml,Web Services,Soap,Wsdl,正在尝试将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/orchestra
<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>
1.
1.
7.
http://services.urbanscience.com/captureservice/ICaptureService/DispositionRequest
1.
1.
7.
到目前为止,我一直有这样的错误:
未捕获的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>";
$soapClient=新的soapClient(“https://braunabilityels.usaitechdev.com/C4CaptureService/services/captureservice.v1.soap.svc?singleWSDL");
$user_param=数组(
'ApplicationId'=>“1”,
'ClientId'=>“1”,
“用户ID”=>“7”
);
$header_param=数组(
“SecurityIdentity”=>$user\u参数,
'ApplicationId'=>“1”,
'ClientId'=>“1”,
“用户ID”=>“7”
);
$header=新的SoapHeader('http://services.urbanscience.com/captureservice“,”Auth“,$header_param,false);
$soapClient->uu设置前置器($header);
$data_param=数组(
“UsaiId”=>“165”,
'LmsId'=>“1946”,
“ReceivedDateTime”=>“2015-03-16T10:59:13.5399397-04:00”,
“ActivityDateTime”=>“2015-03-16T11:34:37.0015824-04:00”,
“ActivityType”=>“已呼叫客户”,
“用户名”=>“Alex”,
“LmsSource”=>“HASCO”
);
$disposition_param=数组(
“处置活动”=>$data\u参数,
);
$xml_param=数组(
“RawXml”=>$disposition\u参数,
);
$CAPTUREQ_参数=数组(
“CaptureRequest”=>$xml\u参数,
);
print_r($soapClient->__soapCall(“DispositionRequest”,数组($capturereq_param));
打印“\n”;
打印“
\n请求:”.htmlspecialchars($soapClient->\uu getLastRequest());
打印“
\n响应:”.htmlspecialchars($soapClient->\uuu getlastress());
打印“”;
我用了几种不同的方法解决了这个问题,但最终我总是在PHP日志中遇到获取http头错误。我已经成功地对其他SOAP服务进行了测试,所以我的想法是这与主捕获服务下有多个请求的请求有关,并且我没有正确地传递信息。我还没有找到任何像这样的例子
我的PHP版本是5.4.24
SOAP应用程序是1.2我用mock for soapclient做了一个示例,它有助于构建请求:谢谢。这确实有助于正确使用XML。因此,它现在正在生成正确的XML。我可以将它复制并粘贴到SOAPUI中,它可以工作,但当我加载php文件时,仍然会出现以下错误“php致命错误:未捕获的SoapFault异常:[HTTP]获取HTTP头时出错”。请将您的php版本和SOAP扩展的版本添加到您的问题中。这可能是一种倒退,但不要担心,让我们一起来保存信息。很高兴看到您能够根据需要创建XML。谢谢。很抱歉回复太晚,你有没有看到那个错误消息上的问答,比如?