Search code examples
phpweb-servicessoapwsdlsoap-client

Soap Client Complex Type PHP Request


I have a web-service with following link I'm trying to access the function name with SubmitRequestType but it seems the function is not exist instead submitAnsiSingle this is the correct function name what I tried so far is ,

$wsdl = 'https://ww3.navicure.com:7000/webservices/NavicureSubmissionService?WSDL';

class SecurityHeaderType {
        private $submitterIdentifier;
        private $originatingIdentifier;
        private $submitterPassword;
        private $submissionId;
        function SecurityHeaderType() {
            $this->submitterIdentifier = '***';
            $this->originatingIdentifier = '****';
            $this->submitterPassword = '****';
            $this->submissionId = '';

        }           
}

class SubmitRequestType {

        private $submitterIdentifier;
        private $originatingIdentifier;
        private $submitterPassword;
        private $submissionId;
        private $timeout;
        private $transactionType;
        private $submittedAnsiVersion;
        private $resultAnsiVersion;
        private $submitterSubmissionId;
        private $processingOption;
        private $payload;
        private $exceptions;

        function SubmitRequestType() {

        $this->submitterIdentifier = '***';
        $this->originatingIdentifier = '***';
        $this->submitterPassword = '**';
        $this->submissionId = '**';
        $this->timeout = 60 ;
        $this->transactionType = "E";
        $this->submittedAnsiVersion = '5010';
        $this->resultAnsiVersion = '5010';
        $this->submitterSubmissionId = '**';
        $this->processingOption = 'R';
        $this->payload = 'EDI-270-Request';
        $this->exceptions = true;
        }
}

$soapheader = new SecurityHeaderType();


$submitrequest = new SubmitRequestType();



    $service = new \SoapClient($wsdl);
    $result= $service->SubmitAnsiSingle($submitrequest);
    echo "<pre/>";print_r($result);

    $types = $service->__getTypes ();
    $functions = $service->__getFunctions ();
    //echo "<pre/>";print_r($types);
    //echo "<pre/>";print_r($functions);

But I'm getting the response like below it seems the request is processing on their end but the SecurityHeaderType is not parsing their end.

stdClass Object
(
    [transactionTyp] => E
    [submitterSubmissionId] => ****
    [submittedAnsiVersion] => 5010
    [resultAnsiVersion] => 5010
    [statusHeader] => stdClass Object
        (
            [statusCode] => 1150
            [statusMessage] => com.navicure.webservices.core.WSCoreException: Account does not exist for ''
            [requestProcessed] => 
        )

)

Any hint will be highly appreciate

Thanks in advance.


Solution

  • I found the solution!. It seems the PHP -> .NET web service comparability issue. So from PHP the complex type SOAP (this kind of format) can't access I found some usefull post here. So I switched SOAP to plain XML request with CURL and it seems working fine!. Also from WSDL link we can extract the request template using this online service . So my final code look like below.

    $xml_data = "<?xml version='1.0' encoding='UTF-8'?>
    <s12:Envelope xmlns:s12='http://www.w3.org/2003/05/soap-envelope'>
      <s12:Header>
        <ns1:SecurityHeaderElement xmlns:ns1='http://www.navicure.com/2009/11/NavicureSubmissionService'>
          <ns1:originatingIdentifier>****</ns1:originatingIdentifier>
          <ns1:submitterIdentifier>****</ns1:submitterIdentifier>
          <ns1:submitterPassword>***</ns1:submitterPassword>
          <ns1:submissionId>?999?</ns1:submissionId>
        </ns1:SecurityHeaderElement>
      </s12:Header>
      <s12:Body>
        <ns1:SubmitAnsiSingleRequestElement xmlns:ns1='http://www.navicure.com/2009/11/NavicureSubmissionService'>
          <ns1:timeout>60</ns1:timeout>
          <ns1:transactionType>E</ns1:transactionType>
          <ns1:submittedAnsiVersion>5010</ns1:submittedAnsiVersion>
          <ns1:resultAnsiVersion>5010</ns1:resultAnsiVersion>
          <ns1:submitterSubmissionId></ns1:submitterSubmissionId>
          <ns1:processingOption>R</ns1:processingOption>
          <ns1:payload>EDI270Payload</ns1:payload>
        </ns1:SubmitAnsiSingleRequestElement>
      </s12:Body>
    </s12:Envelope>";
    $URL = "https://ww3.navicure.com:7000/webservices/NavicureSubmissionService";
    
    $ch = curl_init($URL);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);
    curl_close($ch); 
    
    print_r($output);
    

    Hope this will help someone else in future.