简体   繁体   English

Soap Client复杂类型PHP请求

[英]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 , 我有一个带有以下链接的Web服务,我正在尝试使用SubmitRequestType访问函数名称,但似乎该函数不存在,而是submitAnsiSingle这是到目前为止我尝试过的正确函数名称,

$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. 但是我得到的响应如下所示,似乎请求在它们的末尾处理,但是SecurityHeaderType没有在解析它们的末尾。

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. 提前致谢。

I found the solution!. 我找到了解决方案! It seems the PHP -> .NET web service comparability issue. 似乎PHP-> .NET Web服务可比性问题。 So from PHP the complex type SOAP (this kind of format) can't access I found some usefull post here . 因此,从PHP无法访问复杂类型的SOAP(这种格式),我在这里找到了一些有用的文章。 So I switched SOAP to plain XML request with CURL and it seems working fine!. 所以我将SOAP切换为带有CURL的纯XML请求,似乎工作正常! Also from WSDL link we can extract the request template using this online service . 同样从WSDL链接中,我们可以使用此在线服务提取请求模板。 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. 希望这对将来有帮助。

You might be running into PHP's slightly less than compatible WSDL2 implementation. 您可能会遇到比兼容的WSDL2实现稍差的PHP。 You could try the following and cross your fingers; 您可以尝试以下方法,但要手指交叉;

Headerbody needs to be implemented in the same depth as defined in xml, since I do not have access to navicure's documentation here's example code: 标头主体的实现深度必须与xml中定义的深度相同,因为我无法访问navicure的文档,此处为示例代码:

$headerbody = array('Token' => $someToken, 
                    'Version' => $someVersion, 
                    'UserCredentials'=>array('UserID'=>$UserID, 
                                             'Password'=>$Pwd)); 

//Create Soap Header.        
$header = new SOAPHeader($namespace, 'RequestorCredentials', $headerbody);  

// In case multiple headers are required, create $headers[] = $header, and append to headers after. //如果需要多个标题,则创建$ headers [] = $ header,然后追加到标题之后。

$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 of any use - in case WSDL2 is actually used you might be able to get it to work with nusoap which can be found on sourceforge. 希望这是有任何用处的-如果实际使用WSDL2,您也许可以将其与可在sourceforge上找到的nusoap一起使用。 Although that hasn't been updated in quite a while.. 尽管那已经有一段时间没有更新了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM