1

我有一个使用 wsHttpBinding 的 WCF Web 服务,我从 Java 客户端使用它。我使用 wsimport 从 WSDL 生成代码。java客户端似乎可以很好地创建服务,但是当我在服务上调用一个方法时,客户端只是旋转。

MyService s = new MyService();
IMyService i = s.getWSHttpBindingIMyService();
returnedValue = i.getSomething(2); // method call

java 客户端可以与使用 wsHttpBinding 的 WCF Web 服务进行通信吗?最好的方法是什么?
任何帮助将不胜感激。

4

2 回答 2

5

您肯定希望使用 WSIT 来帮助编写您的客户端,而且使用整个Metro堆栈可能是最简单的。Metro 在其 jars (webservices-rt.jar & webservices-api.jar) 中包含 jaxws-ri、WSIT 和 JAB。

几个步骤让您开始:

  1. WCF 服务的已发布 WSDL 是否包含 WS-Policy 部分?如果没有,请获取该信息并将其放入服务 WSDL 文件的本地本地副本中。在包含 WS-Policy 部分的 WSDL 上重新运行 wsimport。

  2. 在客户的类路径中包含 Metro jar。

  3. 编写一个名为 wsit-client.xml 的文件并将其放入 WEB-INF/classes(或您的类路径)中。这是一个示例。现在,当您使用客户端时,您应该在控制台中看到一条 INFO 消息:WSP5018: Loaded WSIT configuration from file:

  4. If you get stuck on WS-Policy or wsit-client.xml, use Netbeans. I use Eclipse for development, and while I don't really like Netbeans, I've used it as a reference a number of times, because it has configuration settings in the IDE that will enable you to secure web services & write a web service client that needs security, and it'll generate wsit-client.xml & WSDLs with WS-Policy info in them for you. Try writing a web application in Netbeans & pointing to the service's WSDL to generate a web service client there & see what the resulting files look like.

  5. You can get some questions answered here on SO, but the java.net Metro forum is also pretty active, and you can get good support there as well. Just be prepared for answers like "do XYZ in Netbeans/Glassfish".

于 2010-05-04T19:23:37.060 回答
0

可能这会有所帮助:WCF 服务和 Java 客户端

于 2010-05-04T18:45:21.993 回答