Spring Web Service客户端教程或示例必需

我需要跳进Spring Web Service Project,因为我需要实现Spring Web Service的Client Only ..

所以,我已经使用了Spring的客户参考文档 。

所以,我已经了解了Client实现所需的类。

但我的问题就像我做了一些谷歌搜索,但没有得到客户端和服务器的任何正确的例子,因为我可以为我的客户端实现一个示例。

所以,如果有人给我一些链接或教程,从中我可以了解到我的客户端实现将非常感谢。

提前致谢…

在我之前的项目中,我使用Spring 2.5.6,maven2,xmlbeans实现了一个Webservice客户端。

  • xmlbeans负责un / marshal
  • maven2用于项目管理/建筑等。

我在这里粘贴一些代码并希望它们有用。

xmlbeans maven插件conf :(在pom.xml中)

 projectname   src/main/resources true   target/generated-classes/xmlbeans      org.codehaus.mojo xmlbeans-maven-plugin 2.3.2    xmlbeans    true  src/main/resources/    org.codehaus.mojo build-helper-maven-plugin  1.1   add-source generate-sources  add-source     target/generated-sources/xmlbeans        

因此,从上面的conf中,您需要在src / main / resources下放置模式文件(独立或在您的WSDL文件中,您需要提取它们并保存为模式文件。)。 当您使用maven构建项目时,pojos将由xmlbeans生成。 生成的源代码将位于target / generated-sources / xmlbeans下。

然后我们来到Spring conf。 我只是把WS相关的上下文放在这里:

              

最后,看看ws-client java类

 public class MyWsClient extends WebServiceGatewaySupport { //if you need some Dao, Services, just @Autowired here. public MyWsClient(WebServiceMessageFactory messageFactory) { super(messageFactory); } // here is the operation defined in your wsdl public Object someOperation(Object parameter){ //instantiate the xmlbeans generated class, infact, the instance would be the document (marshaled) you are gonna send to the WS SomePojo requestDoc = SomePojo.Factory.newInstance(); // the factory and other methods are prepared by xmlbeans ResponsePojo responseDoc = (ResponsePojo)getWebServiceTemplate().marshalSendAndReceive(requestDoc); // here invoking the WS //then you can get the returned object from the responseDoc. } 

}

我希望示例代码有用。

一步一步的教程 – 使用Spring-WS的Web服务客户端@ http://justcompiled.blogspot.com/2010/11/web-service-client-with-spring-ws.html