2008-09-16 36 views
28

Khi chạy wsdl.exe trên WSDL Tôi tạo ra, tôi nhận được lỗi này:wsdl.exe Lỗi: Không thể nhập ràng buộc '...' từ namespace '...'

Error: Unable to import binding 'SomeBinding' from namespace 'SomeNS'.

  • Unable to import operation 'someOperation'.
  • These members may not be derived.

Tôi sử dụng phong cách tài liệu theo nghĩa đen và theo hiểu biết tốt nhất của tôi, tôi tuân theo tất cả các quy tắc.

Để tổng hợp, tôi có WSDL hợp lệ, nhưng công cụ không thích nó.

Điều tôi đang tìm kiếm là nếu ai đó có nhiều kinh nghiệm với công cụ wsdl.exe và biết về một số bí mật bí mật mà tôi không biết.

+1

Hãy xem [bài viết này] (https://webservices20.blogspot.com/2010/01/interoperability-gotcha-these-members.html). – Steven

Trả lời

42

Tôi đã gặp phải thông báo lỗi tương tự. Sau khi đào một lúc, phát hiện ra rằng người ta có thể cung cấp các tệp xsd ngoài tệp wsdl. Vì vậy, bao gồm/nhập khẩu XSD file ngoài .wsdl vào cuối lệnh wsdl như sau:

wsdl.exe myWebService.wsdl myXsd1.xsd myType1.xsd myXsd2.xsd ...

WSDL cho một số cảnh báo nhưng nó đã tạo ra một giao diện dịch vụ ok.

7

đôi khi bạn phải thay đổi mã ur. thông điệp bán tên không nên giống nhau;)

<wsdl:message name="AnfrageRisikoAnfrageL"> 
    <wsdl:part name="parameters" element="his1_0:typeIn"/> 
</wsdl:message> 
<wsdl:message name="AnfrageRisikoAntwortL"> 
    <wsdl:part name="parameters" element="his1_0:typeOut"/> 
</wsdl:message> 

này:

<wsdl:message name="AnfrageRisikoAnfrageL"> 
    <wsdl:part name="in" element="his1_0:typeIn"/> 
</wsdl:message> 
<wsdl:message name="AnfrageRisikoAntwortL"> 
    <wsdl:part name="out" element="his1_0:typeOut"/> 
</wsdl:message> 
+0

Đó là trường hợp của tôi. Cảm ơn bạn. –

4

@thehhv giải pháp là đúng. Có giải pháp thay thế không yêu cầu bạn thêm xsd s bằng tay.

Đến dịch vụ của bạn sau đó thay vì đi ?wsdl đi đến ?singleWsdl (ảnh chụp màn hình bên dưới)

enter image description here

sau đó lưu trang như .wsdl file (nó sẽ cung cấp .svc để thay đổi nó)

sau đó mở Visual studio command prompt bạn có thể tìm thấy nó trong (Win 7) Start -> All Programs -> Visual studio 2013 -> Công cụ Visual Studio -> VS2013 x64 Native Tools Command Prompt (có thể là một cái gì đó simmilar)
Sau đó chạy lệnh sau trong Visual studio command prompt (trong đó thay vì C: \ WebPricingService.wsdl là nơi bạn đã lưu wsdl, trừ khi nó xảy ra, chúng tôi nghĩ rất giống nhau và chọn cùng tên tệp và vị trí đáng lo ngại)

wsdl.exe C:\WebPricingService.wsdl 

nó sẽ cho bạn một số cảnh báo như @thehhv nói nhưng vẫn tạo ra các khách hàng trong C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\WebPricingService.cs (hoặc bất cứ nơi nào nó đặt nó trên máy tính của bạn - kiểm tra giao diện điều khiển đầu ra mà nó đọc 'tập tin Viết')

enter image description here

Hy vọng điều này sẽ giúp bạn tiết kiệm một số ti tôi.

3

Trong trường hợp của tôi vấn đề là khác nhau, và được mô tả cũng here:

Whenever the name of a part is "parameters" .Net assumed doc/lit/wrapped is used and generates the proxy accordingly. If even though the word "parameters" is used the wsdl is not doc/lit/wrapped (as in the last example) .Net may give us some error. Which error? You guessed correctly: "These members may not be derived". Now we can understand what the error means: .Net tries to omit the root element as it thinks doc/lit/wrapped is used. However this element cannot be removed since it is not dummy - it should be actively chosen by the user out of a few derived types.

Việc sửa chữa là như sau, và làm việc một cách hoàn hảo đối với tôi:

The way to fix it is open the wsdl in a text editor and change the part name from "parameters" to "parameters1". Now .Net will know to generate a doc/lit/bare proxy. This means a new wrapper class will appear as the root parameter in the proxy. While this may be a little more tedious api, this will not have any affect on the wire format and the proxy is fully interoperable.

(nhấn mạnh của tôi)

+0

Giải thích tuyệt vời, không thể tin đây là lần đầu tiên tôi gặp phải vấn đề này sau nhiều năm phát triển. – Vincent

0

Trong trường hợp ai đó chạm vào bức tường này, đây là nguyên nhân gây ra lỗi trong trường hợp của tôi:

Tôi có một hoạt động:

<wsdl:operation name="FormatReport"> 
    <wsdl:documentation>Runs a report, which is returned as the response</wsdl:documentation> 
    <wsdl:input message="FormatReportRequest" /> 
    <wsdl:output message="FormatReportResponse" /> 
</wsdl:operation> 

mà phải mất một đầu vào:

<wsdl:message name="FormatReportRequest"> 
    <wsdl:part name="parameters" element="reporting:FormatReportInput" /> 
</wsdl:message> 

và hoạt động khác:

<wsdl:operation name="FormatReportAsync"> 
    <wsdl:documentation>Creates and submits an Async Report Job to be executed asynchronously by the Async Report Windows Service.</wsdl:documentation> 
    <wsdl:input message="FormatReportAsyncRequest" /> 
    <wsdl:output message="FormatReportAsyncResponse" /> 
</wsdl:operation> 

lấy một đầu vào:

<wsdl:message name="FormatReportAsyncRequest"> 
    <wsdl:part name="parameters" element="reporting:FormatReportInputAsync" /> 
    </wsdl:message> 

Và các yếu tố đầu vào là trường hợp của hai loại:

<xsd:element name="FormatReportInput" type="reporting:FormatReportInputType"/> 
<xsd:element name="FormatReportInputAsync" type="reporting:FormatReportAsyncInputType"/> 

Dưới đây là đánh bắt - loại reporting:FormatReportAsyncInputType kéo dài (có nguồn gốc từ) các loại reporting:FormatReportInputType. Đó là những gì dường như gây nhầm lẫn cho công cụ và gây ra "Những thành viên này có thể không được bắt nguồn." lỗi. Bạn có thể đi xung quanh mà theo đề nghị teh trong câu trả lời được chấp nhận.

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