У меня есть веб-сервис (из моего управления), что я должен говорить. У меня также есть анализатор пакетов на строке, и разработчики веб-сервиса не лежат. Я вижу данные в корректных полях.
Они на самом деле передают все обратно данные, которые я запросил. Но код веб-сервиса, который автоматически генерируется из файла WSDL, дает мне "пустой" как значение.
ОБНОВЛЕНИЕ: Для разъяснения возвращенный объект НЕ является несуществующим. Элементы в объекте являются пустыми. Я не знаю, поможет ли это кому-либо или нет. Я полностью озадачен.
Я использовал их файл WSDL для генерации моей веб-Ссылки. Я проверил свои типы данных с типами данных, которые объявил файл WSDL. И я использовал код, как упомянуто ниже для выполнения вызовов:
DT_MaterialMaster_LookupRequest req = new DT_MaterialMaster_LookupRequest();
req.MaterialNumber = "101*";
req.DocumentNo = "";
req.Description = "Pipe*";
req.Plant = "0000";
MI_MaterialMaster_Lookup_OBService srv = new MI_MaterialMaster_Lookup_OBService();
DT_MaterialMaster_Response resp =
srv.MI_MaterialMaster_Lookup_OB(new DT_MaterialMaster_LookupRequest[] { req });
// Note that the response here is ALWAYS null!!
Console.WriteLine(resp.Status);
Объект resp является фактическим объектом. Это было сгенерировано правильно. Однако поля Status и MaterialData являются всегда пустыми.
Когда я называю веб-сервис, я поместил анализатор пакетов в строку, и я вижу, что отправил следующее (разрывы строки и изрезывания для моей собственной исправности):
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<MT_MaterialMaster_Lookup
xmlns="http://MyCompany.com/SomeCompany/mm/MaterialMasterSearch">
<Request xmlns="">
<MaterialNumber>101*</MaterialNumber>
<Description>Pipe*</Description>
<DocumentNo />
<Plant>0000</Plant>
</Request>
</MT_MaterialMaster_Lookup>
</soap:Body>
</soap:Envelope>
Ответ, который они передают обратно, КАЖЕТСЯ, допустимый ответ (разрывы строки и изрезывания для моей собственной исправности):
<SOAP:Envelope xmlns:SOAP='http://schemas.xmlsoap.org/soap/envelope/'>
<SOAP:Header />
<SOAP:Body>
<n0:MT_MaterialMaster_Response
xmlns:n0='http://MyCompany.com/SomeCompany/mm/MaterialMasterSearch'
xmlns:prx='urn:SomeCompany.com:proxy:BRD:/1SAI/TAS4FE14A2DE960D61219AE:701:2009/02/10'>
<Response>
<Status>No Rows Found</Status>
<MaterialData />
</Response>
</n0:MT_MaterialMaster_Response>
</SOAP:Body>
</SOAP:Envelope>
Состояние показывает, что на самом деле получило данные..., но resp. Состояние и resp. Поля MaterialData являются всегда пустыми. Что я сделал неправильно?
ОБНОВЛЕНИЕ: файл WSDL определяется как:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:p1="http://MyCompany.com/SomeCompany/mm/MaterialMasterSearch" name="MI_MaterialMaster_Lookup_OB" targetNamespace="http://MyCompany.com/SomeCompany/mm/MaterialMasterSearch" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema xmlns="http://MyCompany.com/SomeCompany/mm/MaterialMasterSearch"
targetNamespace="http://MyCompany.com/SomeCompany/mm/MaterialMasterSearch"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="MT_MaterialMaster_Response" type="p1:DT_MaterialMaster_Response" />
<xsd:element name="MT_MaterialMaster_Lookup" type="p1:DT_MaterialMaster_Lookup" />
<xsd:complexType name="DT_MaterialMaster_Response">
<xsd:sequence>
<xsd:element name="Status" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://SomeCompany.com/xi/TextID">d48d03b040af11df99e300145eccb24e</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element maxOccurs="unbounded" name="MaterialData">
<xsd:annotation>
<xsd:appinfo source="http://SomeCompany.com/xi/TextID">64908aa040a511df843700145eccb24e</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="MaterialNumber" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://SomeCompany.com/xi/TextID">64908aa140a511df848500145eccb24e</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element minOccurs="0" name="Description" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://SomeCompany.com/xi/TextID">64908aa240a511df95bf00145eccb24e</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element minOccurs="0" name="DocumentNo" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://SomeCompany.com/xi/TextID">64908aa340a511dfb23700145eccb24e</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element minOccurs="0" name="UOM" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://SomeCompany.com/xi/TextID">3b5f14c040a611df9fbe00145eccb24e</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element minOccurs="0" name="Hierarchy" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://SomeCompany.com/xi/TextID">64908aa440a511dfc65b00145eccb24e</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element minOccurs="0" name="Plant" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://SomeCompany.com/xi/TextID">d48d03b140af11dfb78e00145eccb24e</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element minOccurs="0" name="Procurement" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://SomeCompany.com/xi/TextID">d48d03b240af11dfb87b00145eccb24e</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="DT_MaterialMaster_Lookup">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="Request">
<xsd:annotation>
<xsd:appinfo source="http://SomeCompany.com/xi/TextID">64908aa040a511df843700145eccb24e</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" name="MaterialNumber" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://SomeCompany.com/xi/TextID">64908aa140a511df848500145eccb24e</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element minOccurs="0" name="Description" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://SomeCompany.com/xi/TextID">64908aa240a511df95bf00145eccb24e</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element minOccurs="0" name="DocumentNo" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://SomeCompany.com/xi/TextID">64908aa340a511dfb23700145eccb24e</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element minOccurs="0" name="Plant" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://SomeCompany.com/xi/TextID">64908aa440a511dfc65b00145eccb24e</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="MT_MaterialMaster_Lookup">
<wsdl:part name="MT_MaterialMaster_Lookup" element="p1:MT_MaterialMaster_Lookup" />
</wsdl:message>
<wsdl:message name="MT_MaterialMaster_Response">
<wsdl:part name="MT_MaterialMaster_Response" element="p1:MT_MaterialMaster_Response" />
</wsdl:message>
<wsdl:portType name="MI_MaterialMaster_Lookup_OB">
<wsdl:operation name="MI_MaterialMaster_Lookup_OB">
<wsdl:input message="p1:MT_MaterialMaster_Lookup" />
<wsdl:output message="p1:MT_MaterialMaster_Response" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MI_MaterialMaster_Lookup_OBBinding" type="p1:MI_MaterialMaster_Lookup_OB">
<binding transport="http://schemas.xmlsoap.org/soap/http" xmlns="http://schemas.xmlsoap.org/wsdl/soap/" />
<wsdl:operation name="MI_MaterialMaster_Lookup_OB">
<operation soapAction="http://SomeCompany.com/xi/WebService/soap1.1" xmlns="http://schemas.xmlsoap.org/wsdl/soap/" />
<wsdl:input>
<body use="literal" xmlns="http://schemas.xmlsoap.org/wsdl/soap/" />
</wsdl:input>
<wsdl:output>
<body use="literal" xmlns="http://schemas.xmlsoap.org/wsdl/soap/" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MI_MaterialMaster_Lookup_OBService">
<wsdl:port name="MI_MaterialMaster_Lookup_OBPort" binding="p1:MI_MaterialMaster_Lookup_OBBinding">
<address location="http://bxdwas.MyCompany.com/XISOAPAdapter/MessageServlet?channel=:SOAP_SND_Material_Lookup" xmlns="http://schemas.xmlsoap.org/wsdl/soap/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Вам нужно будет опубликовать WSDL для я, чтобы быть уверенным, но «Web Service Returns Null» почти всегда означает спор о пространствах имен XML - служба отправляет вам данные в одном пространстве имен, а .NET ожидает другого пространства имен.
В этом случае обратите внимание, что большая часть ответа находится в пространстве имен по умолчанию, даже если элемент оболочки находится в пространстве имен http://MyCompany.com/SomeCompany/mm/MaterialMasterSearch
.
Убедитесь, что ссылки на службы актуальны. Это происходит с нами, когда сервис WSDL изменился, но ссылки не обновились.