2013-04-04 37 views
8

Tôi đã tạo WSDL bằng tay chỉ có một thao tác không có tham số đầu vào và không có tham số đầu ra.Bao gồm Loại lược đồ trong tệp WSDL

Tôi nhận được lỗi sau khi tôi cố gắng tạo ra một khách hàng từ WSDL này:

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

Các types (được sử dụng trong các khách hàng) cần phải được tạo ra từ hiện tại XML trong WSDL. Tôi nghĩ rằng, trong khi thêm tham chiếu dịch vụ, công cụ không tạo ra nó do một số lỗi trong XML. xsd có vẻ là vấn đề.

Cần thay đổi gì trong WSDL để tạo proxy?

Lưu ý: Tôi đang cố gắng bao gồm các loại xml được xác định trong chính WSDL. [Tôi không cần một tập tin riêng biệt cho schema 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> 

THAM KHẢO:

  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

Bạn nói không có tham số đầu vào và không có tham số đầu ra. Nhưng, tôi có thể thấy hoạt động của bạn là xác định đầu vào và tham số đầu ra. – IndoKnight

+0

@Indoknight Các tin nhắn này trống. Tôi nghĩ, chúng tôi cần những thông điệp như được giải thích trong http://stackoverflow.com/questions/1108736/wsdl-no-input-best-practice – Lijo

+1

Tôi chưa từng làm việc trên C#, nhưng WSDL có vẻ ổn. Tôi đã kiểm tra SOAPUI. – IndoKnight

Trả lời

1

Tôi đã gọi Inline Schema.Cũng nhờ @Indoknight. WSDL hợp đồng làm việc được đưa ra dưới đây.

Note1: Tiền tố XSD và targetNamespace là có trong lược đồ được sử dụng bên trong wsdl type

Note2: nillable = "true" được áp dụng cho các loại hình sử dụng trong thông điệp trả lời

Note3: Nếu bạn đang nhận được ngoại lệ sau, hãy chắc chắn rằng soapAction là chính xác giống nhau trong WSDL hợp đồng và wsdl được tạo ra từ dịch vụ WCF. Một số công cụ được sử dụng để tạo mã dịch vụ có thể sửa đổi hành động SOAP theo ý muốn của riêng nó.

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 Hành động - Hợp đồng WSDL

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

SOAP Hành động - WSDL tạo

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

Hợp đồng 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 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> 

Yêu cầu

<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> 

đáp ứng

<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

tôi đã dành một thời gian cố gắng để tìm hiểu vấn đề này. Các loại < của bạn > của wsdl không chính xác, nó sẽ giống như dưới đây. Với điều này, bây giờ tôi có thể tạo ra các đồ tạo tác phía máy khách trong Java.

<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> 

CẬP NHẬT

Dựa trên cuộc trò chuyện dưới đây. Đã thêm thuộc tính nillable.

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

Yêu cầu

<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> 

đáp ứng

<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

Cảm ơn. Khi tôi thử nó với giao diện người dùng SOAP, 'myDataResponse' không xuất hiện trong phản hồi trong khi' myData' hiện diện trong đầu vào. Bất kỳ ý tưởng tại sao? – Lijo

+1

Tôi đã tạo dự án SOAPUI với wsdl đã sửa đổi và cũng tạo ra một dịch vụ giả lập. Sau đó, tôi nhận được phản hồi này IndoKnight

+1

bạn có bắn yêu cầu của bạn về dịch vụ web thực tế ? Nếu vậy, đầu ra bạn đang thấy là gì? – IndoKnight

1

wsi.org có một bộ công cụ xác nhận, mà chắc chắn sẽ có giá trị cố gắng.

Lợi ích bổ sung của việc sử dụng các công cụ này là bạn có thể thực sự yêu cầu tuân thủ các đặc tả WSDL.

Các vấn đề liên quan