如何使用PHP soap客户端使用具有复杂类型和安全性的C#WSDL Web服务?

时间:2017-01-14 06:32:49

标签: c# php soap wsdl

这是WSDL:

<?xml version="1.0" encoding="utf-8"?>
<!--Created with Liquid XML Studio 2012 Designer Edition 10.1.7.4256 (http://www.liquid-technologies.com)-->
<!-- The WEX WSDL v1 is based on NCPDP operating rules. “Materials Reproduced With the Consent of © National Council for Prescription Drug Programs, Inc.
2008, 2012 NCPDP” Copyright (c) 2010, 2011 NCPDP. All rights reserved. This work is owned by National Council for Prescription Drug Programs, Inc., 924Ø E. Raintree Drive, Scottsdale, AZ 8526Ø, (48Ø) 477-1ØØØ, ncpdp@ncpdp.org, and protected by the copyright laws of the United States. 17 U.S.C. §1Ø1, et. seq. Permission is given to Council members to copy and use the work or any part thereof in connection with the business purposes of the Council members.   

The work may not be changed or altered except as designated by NCPDP. The work may not be sold, used or exploited for commercial purposes. This permission may be revoked by National Council for Prescription Drug Programs, Inc., at any time. The National Council for Prescription Drugs Programs, Inc. is not responsible for any errors or damage as a result of the use of the work.
NCPDP recognizes the confidentiality of certain information exchanged electronically through the use of its standards. Users should be familiar with the federal, state, and local laws, regulations and codes requiring confidentiality of this information and should utilize the standards accordingly

NOTICE: In addition, this NCPDP Standard contains certain data fields and elements that may be completed by users with the proprietary information of third parties. The use and distribution of third parties' proprietary information without such third parties' consent, or the execution of a license or other agreement with such third party, could subject the user to numerous legal claims. All users are encouraged to contact such third parties to determine whether such information is proprietary and if necessary, to consult with legal counsel to make arrangements for the use and distribution of such proprietary information.-->
<wsdl:definitions xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://schemas.xmlsoap.org/soap/envelope/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://schemas.xmlsoap.org/soap/envelope/">
      <s:element name="NCPDPRequest" type="tns:SoapBodyNCPDP"/>
      <s:complexType name="SoapBodyNCPDP">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="TransactionDetails" type="tns:StandardsType"/>
          <s:element minOccurs="0" maxOccurs="1" name="EnvelopeReferenceID" type="s:string"/>
          <s:element minOccurs="0" maxOccurs="1" name="Payload" type="s:string"/>
        </s:sequence>
      </s:complexType>
      <s:complexType name="StandardsType">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="TransactionStandard" type="s:string"/>
          <s:element minOccurs="0" maxOccurs="1" name="Format" type="s:string"/>
          <s:element minOccurs="0" maxOccurs="1" name="Version" type="s:string"/>
          <s:element minOccurs="0" maxOccurs="1" name="Release" type="s:string"/>
          <s:element minOccurs="0" maxOccurs="1" name="WenoMailNewRx" type="tns:WenoMail"/>
        </s:sequence>
      </s:complexType>
      <s:complexType name="WenoMail">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="WenoMailUUID" type="s:string"/>
          <s:element minOccurs="0" maxOccurs="1" name="PharmacyFAXNumber" type="s:string"/>
        </s:sequence>
      </s:complexType>
      <s:element name="NCPDPResponse" type="tns:SoapBodyNCPDP"/>
      <s:element name="Security" type="tns:Security"/>
      <s:complexType name="Security">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="UserName" type="s:string"/>
          <s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string"/>
        </s:sequence>
        <s:anyAttribute/>
      </s:complexType>
      <s:element name="WEXManageRequest" type="tns:SoapBody"/>
      <s:complexType name="SoapBody">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="Payload" type="s:string"/>
        </s:sequence>
      </s:complexType>
      <s:element name="WEXManageResponse" type="tns:SoapBody"/>
      <s:element name="X12Request" type="tns:SoapBodyX12"/>
      <s:complexType name="SoapBodyX12">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="TransactionDetails" type="tns:StandardsType"/>
          <s:element minOccurs="0" maxOccurs="1" name="EnvelopeReferenceID" type="s:string"/>
          <s:element minOccurs="0" maxOccurs="1" name="Payload" type="s:string"/>
        </s:sequence>
      </s:complexType>
      <s:element name="X12Response" type="tns:SoapBodyX12"/>
      <s:element name="WEXFormularyRequest" type="tns:SoapBodyFormulary"/>
      <s:complexType name="SoapBodyFormulary">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="Payload" type="s:string"/>
        </s:sequence>
      </s:complexType>
      <s:element name="WEXFormularyResponse" type="tns:SoapBodyFormulary"/>
    </s:schema>
  </wsdl:types>
  <wsdl:message name="RealTimeTransactionNCPDPSoapIn">
    <wsdl:part name="NCPDPRequest" element="tns:NCPDPRequest"/>
  </wsdl:message>
  <wsdl:message name="RealTimeTransactionNCPDPSoapOut">
    <wsdl:part name="RealTimeTransactionNCPDPResult" element="tns:NCPDPResponse"/>
  </wsdl:message>
  <wsdl:message name="RealTimeTransactionNCPDPSecurity">
    <wsdl:part name="Security" element="tns:Security"/>
  </wsdl:message>
  <wsdl:message name="RealTimeTransactionWEXManageSoapIn">
    <wsdl:part name="WEXManageRequest" element="tns:WEXManageRequest"/>
  </wsdl:message>
  <wsdl:message name="RealTimeTransactionWEXManageSoapOut">
    <wsdl:part name="RealTimeTransactionWEXManageResult" element="tns:WEXManageResponse"/>
  </wsdl:message>
  <wsdl:message name="RealTimeTransactionWEXManageSecurity">
    <wsdl:part name="Security" element="tns:Security"/>
  </wsdl:message>
  <wsdl:message name="RealTimeTransactionX12SoapIn">
    <wsdl:part name="X12Request" element="tns:X12Request"/>
  </wsdl:message>
  <wsdl:message name="RealTimeTransactionX12SoapOut">
    <wsdl:part name="RealTimeTransactionX12Result" element="tns:X12Response"/>
  </wsdl:message>
  <wsdl:message name="RealTimeTransactionX12Security">
    <wsdl:part name="Security" element="tns:Security"/>
  </wsdl:message>
  <wsdl:message name="RealTimeTransactionFormularyUploadSoapIn">
    <wsdl:part name="WEXFormularyRequest" element="tns:WEXFormularyRequest"/>
  </wsdl:message>
  <wsdl:message name="RealTimeTransactionFormularyUploadSoapOut">
    <wsdl:part name="RealTimeTransactionFormularyUploadResult" element="tns:WEXFormularyResponse"/>
  </wsdl:message>
  <wsdl:message name="RealTimeTransactionFormularyUploadSecurity">
    <wsdl:part name="Security" element="tns:Security"/>
  </wsdl:message>
  <wsdl:portType name="ServiceSoap">
    <wsdl:operation name="RealTimeTransactionNCPDP">
      <wsdl:input message="tns:RealTimeTransactionNCPDPSoapIn"/>
      <wsdl:output message="tns:RealTimeTransactionNCPDPSoapOut"/>
    </wsdl:operation>
    <wsdl:operation name="RealTimeTransactionWEXManage">
      <wsdl:input message="tns:RealTimeTransactionWEXManageSoapIn"/>
      <wsdl:output message="tns:RealTimeTransactionWEXManageSoapOut"/>
    </wsdl:operation>
    <wsdl:operation name="RealTimeTransactionX12">
      <wsdl:input message="tns:RealTimeTransactionX12SoapIn"/>
      <wsdl:output message="tns:RealTimeTransactionX12SoapOut"/>
    </wsdl:operation>
    <wsdl:operation name="RealTimeTransactionFormularyUpload">
      <wsdl:input message="tns:RealTimeTransactionFormularyUploadSoapIn"/>
      <wsdl:output message="tns:RealTimeTransactionFormularyUploadSoapOut"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:portType name="ServiceHttpGet"/>
  <wsdl:portType name="ServiceHttpPost"/>
  <wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="RealTimeTransactionNCPDP">
      <soap:operation soapAction="http://schemas.xmlsoap.org/soap/envelope/RealTimeTransactionNCPDP" style="document"/>
      <wsdl:input>
        <soap:body use="literal"/>
        <soap:header message="tns:RealTimeTransactionNCPDPSecurity" part="Security" use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
        <soap:header message="tns:RealTimeTransactionNCPDPSecurity" part="Security" use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="RealTimeTransactionWEXManage">
      <soap:operation soapAction="http://schemas.xmlsoap.org/soap/envelope/RealTimeTransactionWEXManage" style="document"/>
      <wsdl:input>
        <soap:body use="literal"/>
        <soap:header message="tns:RealTimeTransactionWEXManageSecurity" part="Security" use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
        <soap:header message="tns:RealTimeTransactionWEXManageSecurity" part="Security" use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="RealTimeTransactionX12">
      <soap:operation soapAction="http://schemas.xmlsoap.org/soap/envelope/RealTimeTransactionX12" style="document"/>
      <wsdl:input>
        <soap:body use="literal"/>
        <soap:header message="tns:RealTimeTransactionX12Security" part="Security" use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
        <soap:header message="tns:RealTimeTransactionX12Security" part="Security" use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="RealTimeTransactionFormularyUpload">
      <soap:operation soapAction="http://schemas.xmlsoap.org/soap/envelope/RealTimeTransactionFormularyUpload" style="document"/>
      <wsdl:input>
        <soap:body use="literal"/>
        <soap:header message="tns:RealTimeTransactionFormularyUploadSecurity" part="Security" use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
        <soap:header message="tns:RealTimeTransactionFormularyUploadSecurity" part="Security" use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="RealTimeTransactionNCPDP">
      <soap12:operation soapAction="http://schemas.xmlsoap.org/soap/envelope/RealTimeTransactionNCPDP" style="document"/>
      <wsdl:input>
        <soap12:body use="literal"/>
        <soap12:header message="tns:RealTimeTransactionNCPDPSecurity" part="Security" use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal"/>
        <soap12:header message="tns:RealTimeTransactionNCPDPSecurity" part="Security" use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="RealTimeTransactionWEXManage">
      <soap12:operation soapAction="http://schemas.xmlsoap.org/soap/envelope/RealTimeTransactionWEXManage" style="document"/>
      <wsdl:input>
        <soap12:body use="literal"/>
        <soap12:header message="tns:RealTimeTransactionWEXManageSecurity" part="Security" use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal"/>
        <soap12:header message="tns:RealTimeTransactionWEXManageSecurity" part="Security" use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="RealTimeTransactionX12">
      <soap12:operation soapAction="http://schemas.xmlsoap.org/soap/envelope/RealTimeTransactionX12" style="document"/>
      <wsdl:input>
        <soap12:body use="literal"/>
        <soap12:header message="tns:RealTimeTransactionX12Security" part="Security" use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal"/>
        <soap12:header message="tns:RealTimeTransactionX12Security" part="Security" use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="RealTimeTransactionFormularyUpload">
      <soap12:operation soapAction="http://schemas.xmlsoap.org/soap/envelope/RealTimeTransactionFormularyUpload" style="document"/>
      <wsdl:input>
        <soap12:body use="literal"/>
        <soap12:header message="tns:RealTimeTransactionFormularyUploadSecurity" part="Security" use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal"/>
        <soap12:header message="tns:RealTimeTransactionFormularyUploadSecurity" part="Security" use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="ServiceHttpGet" type="tns:ServiceHttpGet">
    <http:binding verb="GET"/>
  </wsdl:binding>
  <wsdl:binding name="ServiceHttpPost" type="tns:ServiceHttpPost">
    <http:binding verb="POST"/>
  </wsdl:binding>
  <wsdl:service name="Service">
    <wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">
      <soap:address location="https://wexlb.wenoexchange.com/wenox/Service.asmx" />
    </wsdl:port>
    <wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
      <soap12:address location="https://wexlb.wenoexchange.com/wenox/Service.asmx" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

任何人都可以告诉我如何调用它的方法 “RealTimeTransactionNCPDP(SoapBodyNCPDP NCPDPRequest)”?

如何将参数传递给此方法以及如何设置用户名和密码的安全元素?

我得到例外:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at wex_new.Service.SendMessage(Security headerRequest, ISoapBody soapRequest)
   at wex_new.Service.RealTimeTransactionNCPDP(SoapBodyNCPDP NCPDPRequest)
   --- End of inner exception stack trace ---

这是我使用的PHP代码:

$NCPDPRequest = array(
                    "SoapBodyNCPDP" => array(
                            "TransactionDetails"=> array(
                                "TransactionStandard" => 'NCPDP', 
                                "Format" =>'XML', 
                                "Version" =>'10',
                                "Release" =>'6', 
                                "WenoMailNewRx" =>array(
                                    "WenoMailUUID" =>'111111111', 
                                    "PharmacyFAXNumber" =>'99999999999'                                                                             
                                )
                             ), 
                             "EnvelopeReferenceID"=>'EZ-EMR-REF-00001',
                             "Payload"=> "myxmlMsg...."                         
                        )    
                  );
$wsdl = "https://cert.wenoexchange.com/wenox/service.asmx?WSDL"; 
try {
    $soapClient = new SoapClient($wsdl);

} catch (Exception $e) { 
    echo "<h2>Exception Error!</h2>"; 
    echo $e->getMessage(); 
} 

try { 
    $response = $soapClient->RealTimeTransactionNCPDP($NCPDPRequest);   
} catch (SOAPFault $exception) {
    echo $exception;    
    exit;
}

0 个答案:

没有答案