C# wsdl возвращает ответ xml, но переменная все еще имеет значение null

У меня есть WSDL, который возвращает ответ Xml, но когда я пытаюсь назначить его переменной ответа, объект остается нулевым.

Это мой код, вызывающий веб-службу и пытающийся назначить ответ моей переменной:

CustomerReq request = new CustomerReq();
            request.DayPhone = "";
            request.OrganizationCode = "JY-US";
            request.EmailID = "sampleemail@se.com";

            getCustomerInfoResponse response = new getCustomerInfoResponse();


            WSA_CUSTOMER_LOOKUP_OMSClient client = new WSA_CUSTOMER_LOOKUP_OMSClient();
            client.Endpoint.EndpointBehaviors.Add(new FaultFormatingBehavior());

            client.Open();

            response.getCustomerInfoResponse1 = client.getCustomerInfo(request);
            client.Close();

Это запрос Xml:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005    /05/addressing/none">http://WSA_CUSTOMER_LOOKUP_OMS/getCustomerInfo</Action>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<getCustomerInfo OrganizationCode="JY-US" DayPhone="" EmailID="sampleemail@se.com" xmlns="http://WSA_CUSTOMER_LOOKUP_OMS" />
</s:Body>
</s:Envelope>

И получаю ответ:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" />
<soapenv:Body>
<out:getCustomerInfoResponse xmlns:out="http://WSA_CUSTOMER_LOOKUP_OMS">
<CustomerList TotalNumberOfRecords="1">
<Customer AssignedReps="0" BuyerOrganizationCode="" CanConsumeSupplementalCapacity="N" Createprogid="SterlingHttpTester" Createts="2015-03-04T10:09:49-06:00" Createuserid="CustomerName" CustomerID="100207932" CustomerKey="20150304100950117737467" CustomerType="02" ExternalCustomerID="" Lockid="113" MaxAssignRepsOrTeams="0" MaxModifyTS="2018-04-20T15:36:41-05:00" Modifyprogid=".YRCApp" Modifyts="2018-04-20T15:36:41-05:00" Modifyuserid="CustomerName" OrganizationCode="JY-US" RegisteredDate="2015-03-04T10:09:49-06:00" RootCustomerKey="20150304100950117737467" SendsAsn="N" SendsCommitment="N" SendsFuncAck="N" SlotPreferenceType="NONE" Status="10">
<Extn ExtnAccountAllowed="N" ExtnCustomerCreditRating="N" ExtnCustomerCrossRefItem="N" ExtnDirectMailFlag="Y" ExtnEmplFeed="N" ExtnLastOrdDate="2017-10-13" ExtnPayrollDeductionAllowed="N" ExtnPrepayAllowed="N" ExtnRequiredPONumber="N" ExtnShipComplete="N" ExtnShipToEmpl="N" ExtnSubscrStatus="0" ExtnTotCustValue="0.00" ExtnTotalOrders="0" ExtnWebAccountAllowed="N" ExtnWebCustomerID="CustomerName@genesco.com" ExtnWebEnabled="N" ExtnWebPrepayAllowed="N">
</Extn>
<CustomerContactList>
<CustomerContact Company="" Createprogid="SterlingHttpTester" Createts="2015-03-04T10:09:49-06:00" Createuserid="CustomerName" CustomerContactID="100208103" CustomerContactKey="20150304100950117737468" CustomerKey="20150304100950117737467" DayFaxNo="" DayPhone="5555555555" EmailID="CustomerName@genesco.com" EveningFaxNo="" EveningPhone="" FirstName="A" LastName="T" Lockid="3" MiddleName="" MobilePhone="" Modifyprogid="CreateOrder" Modifyts="2017-04-26T08:25:08-05:00" Modifyuserid="CreateOrder" Title="" UserID="">
<CustomerAdditionalAddressList>
<CustomerAdditionalAddress AddressType="" Createprogid="SterlingHttpTester" Createts="2015-03-04T10:09:50-06:00" Createuserid="CustomerName" CustomerAdditionalAddressID="100238485" CustomerAdditionalAddressKey="20150304100950117737470" CustomerContactKey="20150304100950117737468" CustomerKey="20150304100950117737467" IsBillTo="Y" IsDefaultBillTo="Y" IsDefaultShipTo="Y" IsInherited="N" IsShipTo="Y" Lockid="4" Modifyprogid="CreateOrder" Modifyts="2017-04-26T14:48:05-05:00" Modifyuserid="CreateOrder" PersonInfoKey="20170426082509190364347">
<PersonInfo AddressLine1="1415 Rd Pike" AddressLine2="" AddressLine3="" AddressLine4="" AddressLine5="" AddressLine6="" AlternateEmailID="" Beeper="" City="SomeCity" Company="" Country="US" Createprogid="CreateOrder" Createts="2017-04-26T08:25:08-05:00" Createuserid="CreateOrder" DayFaxNo="" DayPhone="5555555555" Department="" EMailID="CustomerName@genesco.com" ErrorTxt="" EveningFaxNo="" EveningPhone="" FirstName="A" HttpUrl="" JobTitle="" LastName="T" Lockid="0" MiddleName="" MobilePhone="" Modifyprogid="CreateOrder" Modifyts="2017-04-26T08:25:08-05:00" Modifyuserid="CreateOrder" OtherPhone="" PersonID="" PersonInfoKey="20170426082509190364347" PreferredShipAddress="" ShortZipCode="37217" State="TN" Suffix="" Title="" UseCount="0" VerificationStatus="" ZipCode="37217" isHistory="N">
<Extn ExtnNormAddLine1="1415 Rd PIKE" ExtnNormCity="SomeCity" ExtnNormState="TN" ExtnNormZipCode="#####">
</Extn>
</PersonInfo>
</CustomerAdditionalAddress>
</CustomerAdditionalAddressList>
</CustomerContact>
</CustomerContactList>
<CustomerPaymentMethodList>
<CustomerPaymentMethod AvailableAccountBalance="0" Createprogid=".YRCApp" Createts="2015-05-11T14:24:27-05:00" Createuserid="CustomerName" CreditCardExpDate="" CreditCardName="" CreditCardNo=" " CreditCardType="" CustomerAccountNo=" " CustomerContactKey="" CustomerKey="20150304100950117737467" CustomerPaymentMethodKey="20150511142427123647013" DisplayCreditCardNo="" DisplayCustomerAccountNo="" DisplayPaymentReference1="4444" DisplayPrimaryAccountNo="4444" FirstName="" IsDefaultMethod="N" IsInherited="N" LastName="" Lockid="0" MiddleName="" Modifyprogid=".YRCApp" Modifyts="2015-05-11T14:24:27-05:00" Modifyuserid="CustomerName" PaymentReference1="4444" PaymentReference2="60.0" PaymentReference3="" PaymentType="CHECK" PaymentTypeGroup="OTHER" PrimaryAccountNo="4444">
</CustomerPaymentMethod>
</CustomerPaymentMethodList>
</Customer>
<Customer AssignedReps="0" BuyerOrganizationCode="" CanConsumeSupplementalCapacity="N" Createprogid=".YRCApp" Createts="2018-08-03T07:15:00-05:00" Createuserid="CustomerName" CustomerID="100272221" CustomerKey="20180803071500281776624" CustomerType="02" ExternalCustomerID="" Lockid="0" MaxAssignRepsOrTeams="0" MaxModifyTS="2018-08-03T07:15:00-05:00" Modifyprogid=".YRCApp" Modifyts="2018-08-03T07:15:00-05:00" Modifyuserid="CustomerName" OrganizationCode="JY-US" RegisteredDate="2018-08-03T07:15:00-05:00" RootCustomerKey="20180803071500281776624" SendsAsn="N" SendsCommitment="N" SendsFuncAck="N" SlotPreferenceType="NONE" Status="10">
<Extn ExtnAccountAllowed="N" ExtnCustomerCreditRating="N" ExtnCustomerCrossRefItem="N" ExtnDirectMailFlag="N" ExtnEmplFeed="N" ExtnPayrollDeductionAllowed="N" ExtnPrepayAllowed="N" ExtnRequiredPONumber="N" ExtnShipComplete="N" ExtnShipToEmpl="N" ExtnSubscrStatus="0" ExtnTotCustValue="0.00" ExtnTotalOrders="0" ExtnWebAccountAllowed="N" ExtnWebEnabled="N" ExtnWebPrepayAllowed="N">
</Extn>
<CustomerContactList>
<CustomerContact Company="" Createprogid=".YRCApp" Createts="2018-08-03T07:15:00-05:00" Createuserid="CustomerName" CustomerContactID="100272403" CustomerContactKey="20180803071501281776625" CustomerKey="20180803071500281776624" DayFaxNo="" DayPhone="5555555555" EmailID="CustomerName@genesco.com" EveningFaxNo="" EveningPhone="" FirstName="Amber" LastName="T" Lockid="0" MiddleName="" MobilePhone="" Modifyprogid=".YRCApp" Modifyts="2018-08-03T07:15:00-05:00" Modifyuserid="CustomerName" Title="" UserID="">
<CustomerAdditionalAddressList>
<CustomerAdditionalAddress AddressType="" Createprogid=".YRCApp" Createts="2018-08-03T07:15:00-05:00" Createuserid="CustomerName" CustomerAdditionalAddressID="100318471" CustomerAdditionalAddressKey="20180803071501281776627" CustomerContactKey="20180803071501281776625" CustomerKey="20180803071500281776624" IsBillTo="Y" IsDefaultBillTo="Y" IsDefaultShipTo="Y" IsInherited="N" IsShipTo="Y" Lockid="0" Modifyprogid=".YRCApp" Modifyts="2018-08-03T07:15:00-05:00" Modifyuserid="CustomerName" PersonInfoKey="20180803071501281776626">
<PersonInfo AddressLine1="#### Rd Pike" AddressLine2="" AddressLine3="" AddressLine4="" AddressLine5="" AddressLine6="" AlternateEmailID="" Beeper="" City="SomeCity" Company="" Country="US" Createprogid=".YRCApp" Createts="2018-08-03T07:15:00-05:00" Createuserid="CustomerName" DayFaxNo="" DayPhone="5555555555" Department="" EMailID="CustomerName@genesco.com" ErrorTxt="" EveningFaxNo="" EveningPhone="" FirstName="Amber" HttpUrl="" IsCommercialAddress="N" JobTitle="" LastName="T" Lockid="0" MiddleName="" MobilePhone="" Modifyprogid=".YRCApp" Modifyts="2018-08-03T07:15:00-05:00" Modifyuserid="CustomerName" OtherPhone="" PersonID="" PersonInfoKey="20180803071501281776626" PreferredShipAddress="" ShortZipCode="37217" State="TN" Suffix="" Title="" UseCount="0" VerificationStatus="" ZipCode="37217-2829" isHistory="N">
<Extn>
</Extn>
</PersonInfo>
</CustomerAdditionalAddress>
</CustomerAdditionalAddressList>
</CustomerContact>
</CustomerContactList>
<CustomerPaymentMethodList>
</CustomerPaymentMethodList>
</Customer>
</CustomerList>
</out:getCustomerInfoResponse>
</soapenv:Body>
</soapenv:Envelope>

Конечная точка из App.config:

<endpoint address="http://som2:7803/WSA_CUSTOMER_LOOKUP_OMS"
            binding="basicHttpBinding" bindingConfiguration="WSA_CUSTOMER_LOOKUP_OMSHttpBinding"
            contract="OMSCustomerLookup.WSA_CUSTOMER_LOOKUP_OMS" name="WSA_CUSTOMER_LOOKUP_OMSHttpPort" />

И определение:

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
public partial class getCustomerInfoResponse {

    [System.ServiceModel.MessageBodyMemberAttribute(Name="getCustomerInfoResponse", Namespace="http://WSA_CUSTOMER_LOOKUP_OMS", Order=0)]
    public OMSWebServicesTest.OMSCustomerLookup.CustomerResp getCustomerInfoResponse1;

    public getCustomerInfoResponse() {
    }

    public getCustomerInfoResponse(OMSWebServicesTest.OMSCustomerLookup.CustomerResp getCustomerInfoResponse1) {
        this.getCustomerInfoResponse1 = getCustomerInfoResponse1;
    }
}

Я тестировал через пользовательский интерфейс SOAP, и он работает правильно, и ответ Xml выглядит правильно, но он не позволяет мне назначить его переменной ответа и не вызывает никаких ошибок. Мы будем очень благодарны за любую идею о том, как это исправить, также дайте мне знать, если мне нужно предоставить какие-либо подробности.

Что вы получаете с var foo =.. вместо response.getCustomerInfoResponse1 = ... ?

Crowcoder 10.08.2018 17:56

извините за задержку, ему присваивается тип CustomerResp и атрибут CustomerList, но он остается пустым.

AWooster 13.08.2018 14:29
0
2
158
1

Ответы 1

Несоответствие схемы было устранено.

Другие вопросы по теме