2009-09-28 111 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