代码之家  ›  专栏  ›  技术社区  ›  codeNinja

邮递员中的Soap请求

  •  0
  • codeNinja  · 技术社区  · 7 年前

    我有一个PHP Soap请求,我正试图将它转移到C#。我以前从未使用过Soap,我对它的请求/响应结构感到非常困惑。

    在我开始编码之前,我试着在邮递员那里测试一下。

    以下是我的邮递员设置:

    URL=http://example.com/service1.svc?singleWsdl
    contentType=text/xml
    

    下面是正在使用的PHP代码,工作正常:

    $client = new SoapClient($wsdlurl, $options);
    $customerData = $client->NewCustAddDC($params);
    

    这里是 $params 是一个如下所示的数组:

    <NewCustomerAdd>
      <InitParameters>
        <InitOrderLines>
          <InitPartDesc />
          <InitPartSKU>test</InitPartSKU>
          <InitQuantity>1</InitQuantity>
        </InitOrderLines>
        <InitOrderLines>
          <InitPartDesc />
          <InitPartSKU>test</InitPartSKU>
          <InitQuantity>1</InitQuantity>
        </InitOrderLines>
        <InitOrderLines>
          <InitPartDesc />
          <InitPartSKU>test</InitPartSKU>
          <InitQuantity>1</InitQuantity>
        </InitOrderLines>
      </InitParameters>
      <TemplateParameters>
        <TemplateOrderLines>
          <TemplatePartDesc />
          <TemplatePartSKU>test</TemplatePartSKU>
          <TemplateQuantity>1</TemplateQuantity>
        </TemplateOrderLines>
        <TemplateOrderLines>
          <TemplatePartDesc />
          <TemplatePartSKU>test</TemplatePartSKU>
          <TemplateQuantity>1</TemplateQuantity>
        </TemplateOrderLines>
        <TemplateOrderLines>
          <TemplatePartDesc />
          <TemplatePartSKU>test</TemplatePartSKU>
          <TemplateQuantity>1</TemplateQuantity>
        </TemplateOrderLines>
      </TemplateParameters>
      <PetInfoParameters>
        <PetInfoLines>
          <DateModified></DateModified>
          <PetFirstName>test</PetFirstName>
          <PetID>1</PetID>
          <PetLastName />
          <ServiceRelated />
          <Species />
          <Weight>1</Weight>
        </PetInfoLines>
        <PetInfoLines>
          <DateModified></DateModified>
          <PetFirstName>test</PetFirstName>
          <PetID>1</PetID>
          <PetLastName />
          <ServiceRelated />
          <Species />
          <Weight>1</Weight>
        </PetInfoLines>
      </PetInfoParameters>
      <SYSPROCustomerID />
      <CustomerFirstName>test</CustomerFirstName>
      <CustomerLastName>test</CustomerLastName>
      <CustomerDesignation />
      <CustomerPrimaryEmail>test</CustomerPrimaryEmail>
      <CustomerEmail2 />
      <CustomerPrimaryPhone>test</CustomerPrimaryPhone>
      <CustomerPhone2 />
      <CustomerBillToAddress1>test</CustomerBillToAddress1>
      <CustomerBillToAddress2>test</CustomerBillToAddress2>
      <CustomerBillToCity>test</CustomerBillToCity>
      <CustomerBillToState>test</CustomerBillToState>
      <CustomerBillToZip>test</CustomerBillToZip>
      <CustomerCountry>test</CustomerCountry>
      <AuthorizeCustomerProfileID>test</AuthorizeCustomerProfileID>
      <AuthorizePaymentProfileID>test</AuthorizePaymentProfileID>
      <ShipAddress1>test</ShipAddress1>
      <ShipAddress2>test</ShipAddress2>
      <ShipCity>test</ShipCity>
      <ShipState>test</ShipState>
      <ShipZip>test</ShipZip>
      <ShipDayofWeek>test</ShipDayofWeek>
      <DeliveryInterval>test</DeliveryInterval>
      <ShippingCosts>test</ShippingCosts>
      <TaxCode />
      <ShipVia>test</ShipVia>
      <DeliveryNotes>test</DeliveryNotes>
      <InitDeliveryDate>test</InitDeliveryDate>
      <FirstRegOrderDeliveryDate>test</FirstRegOrderDeliveryDate>
      <ReferralType>test</ReferralType>
      <ReferralName>test</ReferralName>
      <Last4Digits>test</Last4Digits>
      <InitialCode>test</InitialCode>
      <SpecialInstructions>test</SpecialInstructions>
    </NewCustomerAdd>
    

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        <s:Body>
            <s:Fault>
                <faultcode xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</faultcode>
                <faultstring xml:lang="en-US">The message with Action 'NewCustAddDC' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</faultstring>
            </s:Fault>
        </s:Body>
    </s:Envelope>
    

    请求正文 :

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
            <NewCustAddDC>
         .....the xml from above goes here......
            </NewCustAddDC>
      </soap:Body>
    </soap:Envelope>
    

    我到底做错了什么?

    0 回复  |  直到 7 年前