2009-09-28 110 views
2

我正在將.NET應用程序與一個名爲Hermes2(H2O)的基於Servlet的Java應用程序進行集成。 Java應用程序公開了幾個Web服務,並且我試圖在Visual Studio 2008中爲這些服務創建Web引用。但是,這隻會導致一個空代理服務器,發出以下錯誤消息:「CODEGEN:操作從命名空間' http://service.ebms.edi.cecid.hku.hk/'被忽略,不支持指定use = literal消息的類型。「在.NET中使用Java Webservice

當我試圖通過.NET中的Wsdl.exe用實用程序來運行WSDL,我得到下面的輸出:

Microsoft (R) Web Services Description Language Utility 
[Microsoft (R) .NET Framework, Version 2.0.50727.42] 
Copyright (C) Microsoft Corporation. All rights reserved. 
Warning: This web reference does not conform to WS-I Basic Profile v1.1. 
R2204: A document-literal binding in a DESCRIPTION MUST refer, in each of its soapbind:body element(s), only to wsdl:part element(s) that have been defined using the element attribute. 
- Part 'messageId' of message 'EbmsRequestMsg' from service description with targetNamespace='http://service.ebms.edi.cecid.hku.hk/'. 
- Part 'hasMessage' of message 'EbmsResponseMsg' from service description with targetNamespace='http://service.ebms.edi.cecid.hku.hk/'. 

For more details on the WS-I Basic Profile v1.1, see the specification 
at http://www.ws-i.org/Profiles/BasicProfile-1.1.html. 

Warning: one or more operations were skipped. 
Warnings were encountered. Review generated source comments for more details. 

Writing file 'C:\Files\Temp\Helsekortet\Hermes\wsdl\EbmsMessageReceiverDownload.cs'. 

有誰知道問題是什麼,可能這可怎麼固定?我會假設Hermes2使用某種常見的Webservices庫。有沒有這樣的Java庫產生無效的WSDL?或者這只是.NET不支持的一些功能?

的WSDL如下(我不能在這裏看到的附加文件的任何方式,我沒有一個URL到WSDL對不起張貼臃腫的問題。):

<?xml version="1.0" encoding="utf-8"?> 
<definitions 
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:s="http://www.w3.org/2001/XMLSchema" 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" 
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
xmlns="http://schemas.xmlsoap.org/wsdl/" 
xmlns:p="http://service.ebms.edi.cecid.hku.hk/" 
targetNamespace="http://service.ebms.edi.cecid.hku.hk/"> 
<types> 
</types> 
<message name="EbmsRequestMsg"> 
    <part name="messageId" type="s:string" /> 
</message> 
<message name="EbmsResponseMsg"> 
    <part name="hasMessage" type="s:string" /> 
</message> 
<portType name="EbmsReceiverDownload"> 
    <operation name="Request"> 
    <input message="p:EbmsRequestMsg" /> 
    <output message="p:EbmsResponseMsg" /> 
    </operation> 
</portType> 
<binding name="EbmsSoapHttpReceiverDownload" type="p:EbmsReceiverDownload"> 
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
    <operation name="Request"> 
    <soap:operation soapAction="Ebmsreceiverdownload" style="document" /> 
    <input> 
     <soap:body use="literal" /> 
    </input> 
    <output> 
     <soap:body use="literal" /> 
    </output> 
    </operation> 
</binding> 
<service name="EbmsMessageReceiverDownload"> 
    <documentation>Documentation not available.</documentation> 
    <port name="EbmsReceiverDownload" binding="p:EbmsSoapHttpReceiverDownload"> 
    <soap:address location="http://127.0.0.1:8080/corvus/httpd/ebms/receiver" /> 
    </port> 
</service> 
</definitions> 

希望有人能幫助。

回答

1

我希望有人能提供關於如何解決這個問題指出,馬丁的信息,但沒有人做的事: -/

然而幾個小時的閱讀和努力後,我終於成功地改寫了WSDL由Java應用程序生成的符合.NET的Web服務實現的標準。

看來,所使用的Java Webservices框架是這裏的罪人,但我不知道使用了什麼庫,因爲我不熟悉這些庫中的許多。除了不生成標準的一致性WSDL之外,據我所知,這個應用程序中的web服務還有幾個其他問題在很久以前就已經解決了。例如,使用MIME「multipart/related」傳輸二進制數據,但沒有對SOAP XML中的數據的引用。

我誰想到,.NET吸......不管怎麼說,這裏是產生WSDL類型和消息的部分重寫(冷落的其他部分,因爲這些不被修改)後:

<types> 
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://service.ebms.edi.cecid.hku.hk/" elementFormDefault="qualified"> 
     <xs:element name="messageId" type="xs:string" /> 
     <xs:element name="hasMessage" type="xs:string" /> 
    </xs:schema> 
</types> 
<message name="EbmsRequestMsg"> 
    <part name="messageId" element="p:messageId" /> 
</message> 
<message name="EbmsResponseMsg"> 
    <part name="hasMessage" element="p:hasMessage" /> 
</message> 

感謝Martin爲我指出正確的方向:-)

1
<message name="EbmsRequestMsg"> 
    <part name="messageId" type="s:string" /> 
</message> 
<message name="EbmsResponseMsg"> 
    <part name="hasMessage" type="s:string" /> 

這些必須引用元素聲明,而不是簡單的原始類型。您需要創建一個包含字符串簡單類型的元素包裝器。

+0

你知道這可以做到嗎?我對WSDL並不是很有經驗,所以我希望你能給我一些指點。另外我會認爲生成這個WSDL的Java Webservice庫也應該生成這個呢? – 2009-09-28 12:40:55

+0

這實際上取決於使用哪個Java庫來實現web服務。 – 2009-09-29 09:22:13

+0

是的,它當然是。但一個標準是一個標準;誰會實現或使用不生成標準WSDL的web服務庫? – 2009-10-01 10:24:37