1

Been trying to get a XML SOAP request converted into PHP. This is my first time writing a SOAP request. I'm familiar with PHP but not having any luck. Here's the XML Request I have to replicate:

<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>

The WSDL is https://braunabilityels.usaitechdev.com/C4CaptureService/services/captureservice.v1.soap.svc?singleWSDL

This is what I have so far, but I keep getting this error:

Uncaught SoapFault exception: [HTTP] Error Fetching http headers

My PHP code:

$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>";

I've worked through it several different ways but I end up stuck always getting the Fetching http headers error in my PHP log. I've successfully tested to other SOAP services so my thought is it has something to do with this request having multiple Requests under the main Capture Service and I'm not passing the information correct. I haven't been able to find any examples that look like this.

My version of PHP is 5.4.24 The SOAP Application is 1.2

  • I made an example with a mock for soapclient which can be helpful in building up a request: http://stackoverflow.com/q/28967554/367456 – hakre Apr 03 '15 at 16:14
  • Thanks. That really helped get my XML right. So it's generating the correct XML now. I can copy and paste it into SOAPUI and it works, but when I load the php file I still get this error "PHP Fatal error: Uncaught SoapFault exception: [HTTP] Error Fetching http headers" – Alex Bangle Apr 03 '15 at 18:35
  • Please add your PHP version and the version of the SOAP extension to your question. This might be a regression, but don't fear, let's keep the information together. And great to see you could manage to create the XML as needed. – hakre Apr 03 '15 at 18:43
  • I've added my PHP and SOAP version to the question. Thanks. – Alex Bangle Apr 07 '15 at 14:10
  • Sorry for late reply, have you seen the existing Q&A on that error message, like http://stackoverflow.com/q/920646/367456 ? – hakre Jul 06 '15 at 20:28

0 Answers0