使用没有 WSDL 的 java 的 Soap 客户端服务 - 如何?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10330752/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Soap client service using java without WSDL - How to?
提问by Ram
I use JAX-WS thats ships with jdk to create soap client. Now, the service provider isn't exposing the wsdl. How to create soap client without wsdl, if I know the provided services?
我使用 jdk 附带的 JAX-WS 来创建肥皂客户端。现在,服务提供者没有公开 wsdl。如果我知道提供的服务,如何在没有 wsdl 的情况下创建肥皂客户端?
Edit: I have the freedom to use any soap api/tool, not restricted to JAX-WS.
编辑:我可以自由使用任何soap api/工具,不限于JAX-WS。
Edit2: Here is the message that is shown when the service url is hit. Metadata publishing for this service is currently disabled. And suggests to configure service behavior configuration. I understand the service is done in .Net. But How do I use the provided service behavior related details to access the service in Java?
Edit2:这是点击服务 url 时显示的消息。此服务的元数据发布当前已禁用。并建议配置服务行为配置。我知道该服务是在 .Net 中完成的。但是如何使用提供的服务行为相关的细节来访问 Java 中的服务?
采纳答案by Bitmap
You can create a client service provider which extends javax.xml.ws.Service
, and then override service constructor accepting URL of the remote service you currently have at hand.
您可以创建一个扩展的客户端服务提供者javax.xml.ws.Service
,然后覆盖接受您当前手头的远程服务的 URL 的服务构造函数。
public class Foo extends Service
{
...
public Foo(URL wsdlLocation)
{
super(wsdlLocation, SERVICE);
}
}
And then when building your Provider Binding, you explicitly pass the URL to the service interface.
然后在构建您的 Provider Binding 时,您明确地将 URL 传递给服务接口。
Foo service = new Foo(url);
BindingProvider binding = (BindingProvider)service;
回答by Luca
You can use HttpClient directly but you must hand-code each xml message you send and parse each message you receive. You can also manually create your objects that match your xml and use jaxb to marshall/unmarshall messages.
您可以直接使用 HttpClient,但您必须手动编码您发送的每条 xml 消息并解析您收到的每条消息。您还可以手动创建与您的 xml 匹配的对象并使用 jaxb 来编组/解组消息。