Soap Client Complex Type PHP request

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

 $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 get the answer, as shown below, it seems that the request is being processed from their end, but SecurityHeaderType does not parse 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 would be much appreciated

Thanks in advance.

+5
source share
2 answers

I found a solution !. There seems to be a PHP → .NET web services comparability problem. Thus, from PHP, a complex type of SOAP (this kind of format) cannot be accessed, I found a useful post here . So I switched SOAP to a simple XML query with CURL and it seems to work fine !. Also from the WSDL link we can extract the request template using this online service . So my last code looks 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 helps someone else in the future.

+4
source

You may be working in PHP a little less than a compatible WSDL2 implementation. You can try the following and cross your fingers;

Headerbody should be implemented at the same depth as in xml, since I do not have access to the navigation documentation here is a sample code:

 $headerbody = array('Token' => $someToken, 'Version' => $someVersion, 'UserCredentials'=>array('UserID'=>$UserID, 'Password'=>$Pwd)); //Create Soap Header. $header = new SOAPHeader($namespace, 'RequestorCredentials', $headerbody); 

// If you need multiple headers, create a header $ headers [] = $ and add to the headers after.

 $options = array( 'uri'=>'http://schemas.xmlsoap.org/soap/envelope/', 'style'=>SOAP_RPC, 'use'=>SOAP_ENCODED, 'soap_version'=>SOAP_1_1, 'cache_wsdl'=>WSDL_CACHE_NONE, 'connection_timeout'=>15, 'trace'=>true, 'encoding'=>'UTF-8', 'exceptions'=>true, ); try { $soap = new SoapClient($wsdl, $options); $soap->__setSoapHeaders($header); $data = $soap->SubmitAnsiSingle(array($submitrequest)); } catch(Exception $e) { die($e->getMessage()); } 

Hope this is helpful - if WSDL2 is really used, you can make it work with nusoap , which can be found on sourceforge. Although this has not been updated for quite some time.

+1
source

Source: https://habr.com/ru/post/1273281/


All Articles