Предупреждение: необязательный элемент расширения WSDL body из пространства имен http://schemas.xmlsoap.org/wsdl/soap/ не был обработан.

Я использую Visual Studio 2010, .Net4, Silverlight (4.0.50826.0).

Я создал службу WCF и пытаюсь создать прокси с помощью SlSvcUtil, например:

SlSvcUtil.exe /serializer:DataContractSerializer http://192.128.09.26:8080/Server?wsdl /out:C:\Projets\Client\dService.cs /config:C:\Projets\Client\ServiceReferences.ClientConfig

Когда я добавляю несколько методов с типом клиента, а также у них есть некоторые атрибуты, я получаю это сообщение:

Предупреждение: необязательный элемент расширения WSDL 'body' из пространства имен 'http://schemas.xmlsoap.org/wsdl/soap/ "не обрабатывалась.

XPath: // wsdl: definitions [@ targetNamespace = 'http://tempuri.org/'] / wsdl: привязка [@ name = 'BasicHttpBinding_IService'] / wsdl: operation [@ name = 'GetDefinitionsHavingFre'] / wsdl: output

Если я проигнорирую предупреждение и попытаюсь использовать класс, я получу ошибку NullException при вызове любого метода.

Если я изменю параметр /Serializer:XmlSerializer или любой другой параметр, возможно, будет правильно создать прокси, но я получаю много нулевых ссылок в визуальной студии, поэтому необходимо добавить правильный .dll.

Если я добавлю: System.ServiceModel из Silverlight - атрибут xmlserializerformat не существует System.ServiceModel из .NET - ChannelBase не существует

Если я не использовал метод клиента, моя служба работает нормально, поэтому мой вопрос: есть ли у Silverlight какие-то ограничения при использовании типов клиентов или методов с атрибутами?

Кто-то знает, что можно сделать, чтобы решить эту проблему?

Спасибо,

WSDL:

<?xml version="1.0" encoding="utf-8" ?> 
- <wsdl:definitions name="TestService" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
- <wsdl:types>
- <xsd:schema targetNamespace="http://tempuri.org/Imports">
  <xsd:import schemaLocation="http://192.128.09.26:8080/Server?xsd=xsd0" namespace="http://tempuri.org/" /> 
  <xsd:import schemaLocation="http://192.128.09.26:8080/Server?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" /> 
  <xsd:import schemaLocation="http://192.128.09.26:8080/Server?xsd=xsd10" namespace="http://schemas.datacontract.org/2004/07/DataCompany.Data.Faults" /> 
  <xsd:import schemaLocation="http://192.128.09.26:8080/Server?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/DataCompany.Data.PortalModel" /> 
  <xsd:import schemaLocation="http://192.128.09.26:8080/Server?xsd=xsd3" namespace="http://schemas.datacontract.org/2004/07/System.Data.Objects.DataClasses" /> 
  <xsd:import schemaLocation="http://192.128.09.26:8080/Server?xsd=xsd4" namespace="http://schemas.datacontract.org/2004/07/System.Data" /> 
  <xsd:import schemaLocation="http://192.128.09.26:8080/Server?xsd=xsd5" namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays" /> 
  <xsd:import schemaLocation="http://192.128.09.26:8080/Server?xsd=xsd6" namespace="http://schemas.datacontract.org/2004/07/DataCompany.Data.Components" /> 
  <xsd:import schemaLocation="http://192.128.09.26:8080/Server?xsd=xsd7" namespace="http://schemas.datacontract.org/2004/07/System" /> 
  <xsd:import schemaLocation="http://192.128.09.26:8080/Server?xsd=xsd8" namespace="http://schemas.datacontract.org/2004/07/DataCompany.Data" /> 
  <xsd:import schemaLocation="http://192.128.09.26:8080/Server?xsd=xsd9" namespace="http://schemas.datacontract.org/2004/07/DataCompany.Data.LocalizationManagement" /> 
  </xsd:schema>
  </wsdl:types>
- <wsdl:message name="ITestService_StatusService_InputMessage">
  <wsdl:part name="parameters" element="tns:StatusService" /> 
  </wsdl:message>
- <wsdl:message name="ITestService_StatusService_OutputMessage">
  <wsdl:part name="parameters" element="tns:StatusServiceResponse" /> 
  </wsdl:message>
- <wsdl:message name="ITestService_getData_InputMessage">
  <wsdl:part name="parameters" element="tns:getData" /> 
  </wsdl:message>
- <wsdl:message name="ITestService_getData_OutputMessage">
  <wsdl:part name="parameters" element="tns:getDataResponse" /> 
  </wsdl:message>
- <wsdl:message name="ITestService_getTime_InputMessage">
  <wsdl:part name="parameters" element="tns:getTime" /> 
  </wsdl:message>
- <wsdl:message name="ITestService_getTime_OutputMessage">
  <wsdl:part name="parameters" element="tns:getTimeResponse" /> 
  </wsdl:message>
- <wsdl:message name="ITestService_getText_InputMessage">
  <wsdl:part name="parameters" element="tns:getText" /> 
  </wsdl:message>
- <wsdl:message name="ITestService_getText_OutputMessage">
  <wsdl:part name="parameters" element="tns:getTextResponse" /> 
  </wsdl:message>
- <wsdl:message name="ITestService_SaveEntity_InputMessage">
  <wsdl:part name="parameters" element="tns:SaveEntity" /> 
  </wsdl:message>
- <wsdl:message name="ITestService_SaveEntity_OutputMessage">
  <wsdl:part name="parameters" element="tns:SaveEntityResponse" /> 
  </wsdl:message>
- <wsdl:message name="ITestService_SaveEntity_DatabaseFaultFault_FaultMessage">
  <wsdl:part name="detail" element="q1:DatabaseFault" xmlns:q1="http://schemas.datacontract.org/2004/07/DataCompany.Data.Faults" /> 
  </wsdl:message>
- <wsdl:portType name="ITestService">
- <wsdl:operation name="StatusService">
  <wsdl:input wsaw:Action="http://tempuri.org/ITestService/StatusService" message="tns:ITestService_StatusService_InputMessage" /> 
  <wsdl:output wsaw:Action="http://tempuri.org/ITestService/StatusServiceResponse" message="tns:ITestService_StatusService_OutputMessage" /> 
  </wsdl:operation>
- <wsdl:operation name="getData">
  <wsdl:input wsaw:Action="http://tempuri.org/ITestService/getData" message="tns:ITestService_getData_InputMessage" /> 
  <wsdl:output wsaw:Action="http://tempuri.org/ITestService/getDataResponse" message="tns:ITestService_getData_OutputMessage" /> 
  </wsdl:operation>
- <wsdl:operation name="getTime">
  <wsdl:input wsaw:Action="http://tempuri.org/ITestService/getTime" message="tns:ITestService_getTime_InputMessage" /> 
  <wsdl:output wsaw:Action="http://tempuri.org/ITestService/getTimeResponse" message="tns:ITestService_getTime_OutputMessage" /> 
  </wsdl:operation>
- <wsdl:operation name="getText">
  <wsdl:input wsaw:Action="http://tempuri.org/ITestService/getText" message="tns:ITestService_getText_InputMessage" /> 
  <wsdl:output wsaw:Action="http://tempuri.org/ITestService/getTextResponse" message="tns:ITestService_getText_OutputMessage" /> 
  </wsdl:operation>
- <wsdl:operation name="SaveEntity">
  <wsdl:input wsaw:Action="http://tempuri.org/ITestService/SaveEntity" message="tns:ITestService_SaveEntity_InputMessage" /> 
  <wsdl:output wsaw:Action="http://tempuri.org/ITestService/SaveEntityResponse" message="tns:ITestService_SaveEntity_OutputMessage" /> 
  <wsdl:fault wsaw:Action="http://tempuri.org/ITestService/SaveEntityDatabaseFaultFault" name="DatabaseFaultFault" message="tns:ITestService_SaveEntity_DatabaseFaultFault_FaultMessage" /> 
  </wsdl:operation>
  </wsdl:portType>
- <wsdl:binding name="BasicHttpBinding_ITestService" type="tns:ITestService">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
- <wsdl:operation name="StatusService">
  <soap:operation soapAction="http://tempuri.org/ITestService/StatusService" style="document" /> 
- <wsdl:input>
  <soap:body use="literal" /> 
  </wsdl:input>
- <wsdl:output>
  <soap:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="getData">
  <soap:operation soapAction="http://tempuri.org/ITestService/getData" style="document" /> 
- <wsdl:input>
  <soap:body use="literal" /> 
  </wsdl:input>
- <wsdl:output>
  <soap:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="getTime">
  <soap:operation soapAction="http://tempuri.org/ITestService/getTime" style="document" /> 
- <wsdl:input>
  <soap:body use="literal" /> 
  </wsdl:input>
- <wsdl:output>
  <soap:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="getText">
  <soap:operation soapAction="http://tempuri.org/ITestService/getText" style="document" /> 
- <wsdl:input>
  <soap:body use="literal" /> 
  </wsdl:input>
- <wsdl:output>
  <soap:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="SaveEntity">
  <soap:operation soapAction="http://tempuri.org/ITestService/SaveEntity" style="document" /> 
- <wsdl:input>
  <soap:body use="literal" /> 
  </wsdl:input>
- <wsdl:output>
  <soap:body use="literal" /> 
  </wsdl:output>
- <wsdl:fault name="DatabaseFaultFault">
  <soap:fault name="DatabaseFaultFault" use="literal" /> 
  </wsdl:fault>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:service name="TestService">
- <wsdl:port name="BasicHttpBinding_ITestService" binding="tns:BasicHttpBinding_ITestService">
  <soap:address location="http://192.128.09.26:8080/Server" /> 
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>


person Gabriel Aphonso    schedule 05.04.2011    source источник
comment
Если возможно добавить WSDL из службы к вашему вопросу, вы можете получить некоторые ответы.   -  person Sixto Saez    schedule 05.04.2011


Ответы (1)


Нашел проблему.

После создания прокси с SlSvcUtil и добавления .cs в мой проект в Visual Studio я получил эту ошибку:

Тип или имя пространства имен «XmlSerializerFormatAttributeAttribute» не существует в пространстве имен «System.ServiceModel» (вам не хватает ссылки на сборку?)

Прежде всего я попытался изменить System.Service.Model с версии Silverlight на версию .Net, но у меня возникли другие ошибки.

Итак, я нашел то, что было необходимо, используйте /serializer:DataContractSerializer в SlSvcUtil; после этого ошибка была решена. Однако при создании прокси я получил предупреждение WSDL.

РЕШЕНИЕ

  1. # P6 #
    SlSvcUtil.exe http://192.128.09.26:8080/Server /out:C:\Projets\Client\dService.cs /config:C:\Projets\Client\ServiceReferences.ClientConfig
    
    # P7 #
    # P8 #
  2. Я добавил следующую dll:

    • System.Xml.Serialization.dll - (Runtime Version v2.0.50727)

Вывод

Visual Studio не смогла найти ссылку внутри ServiceModel.dll, а ServiceModel там была, поэтому я никогда не думал добавлять другой .dll, потому что правильная dll уже была добавлена.

Буквально вчера я попытался добавить System.Xml.Serialization.dll, и теперь все работает нормально.

person Gabriel Aphonso    schedule 19.04.2011