调用使用 xsd:anyType 的 SOAP WebService
我需要调用一个 WebService,它有一个定义为 xsd:anyType 数组的参数,定义如下:
<complexType name='ArrayOfAnyType'>
<complexContent>
<restriction base='soapenc:Array'>
<attribute ref='soapenc:arrayType' wsdl:arrayType ='xsd:anyType[]'/>
</restriction>
</complexContent>
</complexType>
返回类型也是 xsd:anyType 类型,如下所示:
<message name='RunTask.runTaskInput'>
<part name='taskName' type='xsd:string'/>
<part name='args' type='ns2:ArrayOfAnyType'/>
</message>
<message name='RunTask.runTaskOutput'>
<part name='return' type='xsd:anyType'/>
</message>
WebService 实际上是一个可以执行大量操作的服务器不同的任务,其中任务可以由服务器的用户配置(每个任务都有自己的特定参数)。
到目前为止,我可以使用 Microsoft 的 WSDL 实用程序为此 Web 服务生成 C# 客户端代理。如果我正确地将所有参数转换为 .Net“对象”类型,则可以轻松使用生成的 C# 代码。
我现在需要为这个 Web 服务生成一个 Java 客户端(说实话,我只是 Java 的初学者)。似乎有一个名为 WSDL2JAVA 的实用程序,我在 http://ws.apache.org/muse/docs/2.0.0/tutorial/01-install-muse.html。但如果我运行它,它会给我以下错误:
警告:[ID = 'NoWSRPSchema'] 否 找到 WS-RP 架构。 java.lang.RuntimeException: [ID = 'NotDocLiteral'] WSDL 操作 'runTask' 不是文档字面量,因为 它定义了一条超过 其 SOAP 主体的一个消息部分。 文档消息的 SOAP 正文 应包含一个根请求 元素(带有操作名称) 具有零个或多个子元素( 参数)。 在 org.apache.muse.tools.inspector.ResourceInspector.getInputName(ResourceInspector.java:486) 在 org.apache.muse.tools.inspector.ResourceInspector.createJavaMethod(ResourceInspector.java:329) 在 org.apache.muse.tools.inspector.ResourceInspector.getOperations(ResourceInspector.java:570) 在 org.apache.muse.tools.inspector.ResourceInspector.run(ResourceInspector.java:888) 在 org.apache.muse.tools.generator.analyzer.SimpleAnalyzer.inspect(SimpleAnalyzer.java:409) 在 org.apache.muse.tools.generator.analyzer.SimpleAnalyzer.analyze(SimpleAnalyzer.java:348) 在 org.apache.muse.tools.generator.Wsdl2Java.run(Wsdl2Java.java:178) 在 org.apache.muse.tools.generator.Wsdl2Java.main(Wsdl2Java.java:270)
严重:[ID = 'CodeGenFailed'] 代码 生成失败,查看异常 信息如下。
捕获到异常:[ID = 'NotDocLiteral'] WSDL 操作 'runTask' 不是文档字面量,因为 它定义了一条超过 其 SOAP 主体的一个消息部分。 文档消息的 SOAP 正文 应包含一个根请求 元素(h 为操作名称) 具有零个或多个子元素( 参数)。
我认为这里不支持 xsd:anyType 。
为该 Web 服务生成代理类的更简单方法是什么? 最好尽可能简单,就像 WSDL 为我创建 C# 代理一样。
I need to call a WebService which has an argument that's defined as an array of xsd:anyType, defined like this:
<complexType name='ArrayOfAnyType'>
<complexContent>
<restriction base='soapenc:Array'>
<attribute ref='soapenc:arrayType' wsdl:arrayType ='xsd:anyType[]'/>
</restriction>
</complexContent>
</complexType>
and the return type is also of type xsd:anyType, like this:
<message name='RunTask.runTaskInput'>
<part name='taskName' type='xsd:string'/>
<part name='args' type='ns2:ArrayOfAnyType'/>
</message>
<message name='RunTask.runTaskOutput'>
<part name='return' type='xsd:anyType'/>
</message>
The WebService is actually a server which can execute lots of different tasks, where the tasks can be configured by the user of the server (and each task has its own specific arguments).
Until now I could generate C# client proxies for this web service using Microsoft's WSDL utility. The generated C# code could easily be used, provided that I correctly cast all arguments to .Net 'object' type.
I now need to generate a Java client for this web service (and to be honest, I'm only a beginner in Java). There seem to be a utility called WSDL2JAVA, which I found at http://ws.apache.org/muse/docs/2.0.0/tutorial/01-install-muse.html. But if I run it, it gives me the following errors:
WARNING: [ID = 'NoWSRPSchema'] No
WS-RP schema found.
java.lang.RuntimeException: [ID =
'NotDocLiteral'] The WSDL operation
'runTask' is not doc-literal because
it defines a message with more than
one message part for its SOAP Body.
The SOAP Body of a doc-literal message
should contain one root request
element ( with the operation name)
with zero or more child elements (the
parameters).
at org.apache.muse.tools.inspector.ResourceInspector.getInputName(ResourceInspector.java:486)
at org.apache.muse.tools.inspector.ResourceInspector.createJavaMethod(ResourceInspector.java:329)
at org.apache.muse.tools.inspector.ResourceInspector.getOperations(ResourceInspector.java:570)
at org.apache.muse.tools.inspector.ResourceInspector.run(ResourceInspector.java:888)
at org.apache.muse.tools.generator.analyzer.SimpleAnalyzer.inspect(SimpleAnalyzer.java:409)
at org.apache.muse.tools.generator.analyzer.SimpleAnalyzer.analyze(SimpleAnalyzer.java:348)
at org.apache.muse.tools.generator.Wsdl2Java.run(Wsdl2Java.java:178)
at org.apache.muse.tools.generator.Wsdl2Java.main(Wsdl2Java.java:270)SEVERE: [ID = 'CodeGenFailed'] Code
generation failed, see the exception
information below.An exception was caught: [ID =
'NotDocLiteral'] The WSDL operation
'runTask' is not doc-literal because
it defines a message wi th more than
one message part for its SOAP Body.
The SOAP Body of a doc-literal message
should contain one root request
element (wit h the operation name)
with zero or more child elements (the
parameters).
I looks to me as the xsd:anyType is not supported here.
What is the easier way to generate a proxy-class for this web service?
Preferably as easy as possible, just like WSDL created the C# proxy for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论