java - 在 .NET 中使用 Java Web 服务

标签 java .net web-services wsdl

我正在致力于将 .NET 应用程序与名为 Hermes2 (H2O) 的基于 Servlet 的 Java 应用程序相集成。 Java 应用程序公开了多个 Web 服务,我正在尝试在 Visual Studio 2008 中创建对这些服务的 Web 引用。但这只会导致一个空代理,并附有错误消息:“CODEGEN:操作绑定(bind)‘请求’来自命名空间‘ http://service.ebms.edi.cecid.hku.hk/ ' 被忽略。不支持为 use=literal 消息指定类型。"。

当我尝试通过 .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 使用某种通用的 Web 服务库。是否有任何此类 Java 库会生成无效的 WSDL,或者这仅仅是 .NET 不支持的某些功能?

WSDL 如下(我在这里看不到任何附加文件的方式,而且我没有 WSDL 的 URL。抱歉发布了一个臃肿的问题):

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

希望大家帮忙。

最佳答案

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

这些必须引用元素声明而不是原始的简单类型。您需要创建一个包含字符串简单类型的元素包装器。

关于java - 在 .NET 中使用 Java Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1486647/

相关文章:

c# - DataTable 到 CSV 日期格式

java - 从 Android 调用 Asmx

java - 带有同步列表的 ConcurrentModificationException

java - 如何使用多维数组列表?

c# - CredUIPromptForCredentials 强制手动选择用户名

c# - 使用 DllImport 调用 C++ 函数

使用安装项目安装时未显示 Windows 服务

web-services - 在 nuSoap 中发送图像或其他数据

java - 无法访问 Java 中的 JVM 自定义属性

Java/Android递归文件空指针异常