2013-04-04 17 views
8

Utworzono ręcznie WSDL, który ma tylko jedną operację bez parametru wejściowego i bez parametru wyjściowego.Dołącz typ schematu do pliku WSDL

otrzymuję następujący błąd, gdy próbuję stworzyć klienta z tym WSDL:

Cannot import wsdl:portType Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter Error: Schema with target namespace ' http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/ ' could not be found. XPath to Error Source: //wsdl:definitions[@targetNamespace=' http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/ ']/wsdl:portType[@name='GAMEAssociateIntf'] C:\toolbox\BlueTest\BloodRedTest\BloodRedTest\Service

types (stosowany w kliencie) muszą być generowane z obecnego XML w pliku WSDL. Myślę, że podczas dodawania odwołania do usługi narzędzie nie może go utworzyć z powodu błędu w kodzie XML. Wydaje się, że problem dotyczy modelu xsd.

Jakie zmiany należy wprowadzić w pliku WSDL, aby utworzyć serwer proxy?

Uwaga: Próbuję dołączyć typy XML zdefiniowane w samym WSDL. [Nie muszę osobny plik dla schematu defenition]

WSDL

<?xml version="1.0" encoding="UTF-8"?> 
<definitions name="GAMEAssociate" 
     targetNamespace="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/" 
     xmlns:tns="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/" 
     xmlns="http://schemas.xmlsoap.org/wsdl/" 
     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
     xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
     xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
     xmlns:wsp="http://www.w3.org/ns/ws-policy" 
     > 

<types> 
<xsd:schema> 
</xsd:schema> 

<xsd:element name="myData"> 
    <xsd:complexType /> 
</xsd:element> 

<xsd:element name="myDataResponse"> 
    <xsd:complexType /> 
</xsd:element> 

</types> 

<message name="getAllVicePresidentsRequest"> 
<part element="tns:myData" name="getAllVicePresidentsRequest"/> 
</message> 

<message name="getAllVicePresidentsResponse"> 
<part element="tns:myDataResponse" name="getAllVicePresidentsResponse"/> 
</message> 

<portType name="GAMEAssociateIntf"> 
<operation name="getAllVicePresidents"> 
    <input message="tns:getAllVicePresidentsRequest"/> 
    <output message="tns:getAllVicePresidentsResponse"/> 
</operation> 
</portType> 

<binding name="GAMEAssociateIntfBinding" type="tns:GAMEAssociateIntf"> 
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 

<operation name="getAllVicePresidents"> 
    <soap:operation soapAction="http://www.xmlns.mycompany.com/GAME/wsdl/AssociateIntf/1.4/getAllVicePresidentsRequest" 
        style="document"/> 
    <input> 
    <soap:body use="literal"/> 
    </input> 
    <output> 
    <soap:body use="literal"/> 
    </output> 

</operation> 

</binding> 

<service name="GAMEAssociate"> 
<port binding="tns:GAMEAssociateIntfBinding" name="GAMEAssociateSOAP"> 
    <soap:address location="http://localhost:8014/associateservice/GAMEAssociate.svc"/> 
</port> 
</service> 

</definitions> 

REFERENCJE:

  1. WSDL - no input - best practice
  2. What does this WCF error mean: "Custom tool warning: Cannot import wsdl:portType"
  3. Writing a WSDL 1.1 Web Service Contract by Hand
  4. Writing Contract-First Web Services
  5. generate wcf server code from wsdl files
  6. How to get wsdl input and output names to appear
  7. Inline Schema
  8. Hand rolled SOAP request
+0

Mówiłeś żaden parametr wejściowy i nie parametr wyjściowy. Ale widzę, że twoja operacja definiuje parametr wejściowy i wyjściowy. – IndoKnight

+0

@Indoknight Te wiadomości są puste. Myślę, że potrzebujemy takich wiadomości, jak wyjaśniono w http://stackoverflow.com/questions/1108736/wsdl-no-input-best-practice – Lijo

+1

Nie pracowałem nad C#, ale WSDL wygląda dobrze. Sprawdziłem SOAPUI. – IndoKnight

Odpowiedz

1

Podałem Inline Schema.Dzięki @Indoknight również. Umowa robocza WSDL znajduje się poniżej.

Note1: Przedrostek xsd i targetNamespace istnieje w schemacie, który jest używany wewnątrz wsdl type

UWAGA2: nillable = „true” jest stosowane dla danego typu używanego w komunikacie odpowiedzi

Uwaga 3: W przypadku otrzymujesz następujący wyjątek, upewnij się, że soapAction jest dokładnie taki sam w WSDL kontraktu i w kodzie WSDL wygenerowanym z usługi WCF. Niektóre narzędzia używane do generowania kodu usługi mogą modyfikować akcję SOAP według własnej woli.

Faultcod: a:ActionNotSupported

Faultstring: The message with Action ' http://www.xmlns.mycompany.com/GAME/wsdl/AssociateIntf/1.4/getAllVicePresidentsRequest ' 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).

SOAP Action - Umowa WSDL

<soap:operation soapAction="http://www.xmlns.mycompany.com/GAME/wsdl/AssociateIntf/1.4/getAllVicePresidentsRequest" 

SOAP Akcja - Wygenerowane WSDL

<soap:operation soapAction="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/IGAMEAssociateIntf/getAllVicePresidents" 

WSDL kontraktu

<?xml version="1.0" encoding="UTF-8"?> 
<definitions name="GAMEAssociate" 
    targetNamespace="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/" 
    xmlns:tns="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/" 
    xmlns="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:wsp="http://www.w3.org/ns/ws-policy" 
    > 

<types> 
<xsd:schema targetNamespace="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/" 
      xmlns:xsd="http://www.w3.org/2001/XMLSchema" > 
    <xsd:element name="myData"> 
    <xsd:complexType /> 
    </xsd:element> 
    <xsd:element name="myDataResponse" nillable="true"> 
    <xsd:complexType /> 
    </xsd:element> 
</xsd:schema> 
</types> 

<message name="getAllVicePresidentsRequest"> 
<part element="tns:myData" name="getAllVicePresidentsRequest"/> 
</message> 

<message name="getAllVicePresidentsResponse"> 
<part element="tns:myDataResponse" name="getAllVicePresidentsResponse"/> 
</message> 

<portType name="GAMEAssociateIntf"> 
<operation name="getAllVicePresidents"> 
    <input message="tns:getAllVicePresidentsRequest"/> 
    <output message="tns:getAllVicePresidentsResponse"/> 
</operation> 
</portType> 

<binding name="GAMEAssociateIntfBinding" type="tns:GAMEAssociateIntf"> 
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 
<operation name="getAllVicePresidents"> 
    <soap:operation soapAction="http://www.xmlns.mycompany.com/GAME/wsdl/AssociateIntf/1.4/getAllVicePresidentsRequest" 
        style="document"/> 
    <input> 
    <soap:body use="literal"/> 
    </input> 
    <output> 
    <soap:body use="literal"/> 
    </output> 
</operation> 
</binding> 

<service name="GAMEAssociate"> 
<port binding="tns:GAMEAssociateIntfBinding" name="GAMEAssociateSOAP"> 
    <soap:address location="http://localhost:8014/associateservice/GAMEAssociate.svc"/> 
</port> 
</service> 

</definitions> 

Zapytanie

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/"> 
<soapenv:Header/> 
<soapenv:Body> 
    <ns:myData/> 
</soapenv:Body> 
</soapenv:Envelope> 

Response

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <myDataResponse xsi:nil="true" xmlns="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/"/> 
</s:Body> 
</s:Envelope> 
6

Spędziłem trochę czasu próbuje dowiedzieć się problemy. Sekcja < typów > we wsdl jest niepoprawna, powinna być jak poniżej. Dzięki temu mogę teraz generować artefakty po stronie klienta w Javie.

<types> 
<schema targetNamespace="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/" 
      xmlns="http://www.w3.org/2001/XMLSchema"> 
    <element name="myData"> 
    <complexType/> 
    </element> 

    <element name="myDataResponse"> 
    <complexType/> 
    </element> 
</schema></types> 

UPDATE

Na podstawie poniższej rozmowie. Dodano atrybut nillable.

<element name="myDataResponse" nillable="true"> 
<complexType/> 
</element> 

Zapytanie

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/"> 
<soapenv:Header/> 
<soapenv:Body> 
    <ns:myData/> 
</soapenv:Body> 
</soapenv:Envelope> 

Response

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <myDataResponse xsi:nil="true" xmlns="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/"/> 
</s:Body> 
</s:Envelope> 
+0

Dzięki. Kiedy próbowałem go z interfejsem SOAP, 'myDataResponse' nie pojawia się w odpowiedzi, podczas gdy' myData' jest obecne w danych wejściowych. Każdy pomysł, dlaczego? – Lijo

+1

Utworzono projekt SOAPUI ze zmodyfikowanym kodem wsdl, a także utworzono fałszywą usługę. Następnie otrzymałem odpowiedź IndoKnight

+1

Czy wypalanie prośby o rzeczywistej usługi internetowej ? Jeśli tak, jakie dane wyjściowe widzisz? – IndoKnight

1

wsi.org posiada zestaw narzędzi walidacji, które z pewnością warto spróbować.

Dodatkową korzyścią płynącą z używania tych narzędzi jest to, że można wówczas uzyskać zgodność ze specyfikacją WSDL.

Powiązane problemy