简体   繁体   中英

How to create and test a SOAP and HTTP web service in Java, Maven, and Spring

Essentially I am trying to create a simple SOAP Webservice in Java, Maven, and Spring. I have tried following tutorials, books, and just hacking at it. Can anyone help please.

Background

  • We have a project which is effectively a bunch of libraries boiling to a handful of interfaces.
  • The project is a maven project created using the spring framework, mainly roo.
  • We're running the STS eclipse IDE which has a vmware (vSphere) virtual web server.

What I'm trying to achieve

  • Add web services for SOAP and HTTP endpoints.
  • Have existing WSDLs for these web services.

What I have tried:

1. Creating a web service with "Top down Java bean Web Service" type pointing to the wsdl, VMware server.

  • Creates a web service project separate from my existing project.
  • Web Service seems to be synchronised in the virtual web server.
  • Right clicking to the home page for the web server results in the 404 error.
  • Looking at the localhost:8080 shows a running virtual web server page.

Problems:

  • Project created is in the eclipse workspace rather than the source folders. This results in source control commitment issues.
  • Is it normal for all web services to be a separate project per web service in eclipse?
  • Right clicking to the home page for the web server results in the 404 error.
  • Not sure how to debug the 404 error to determine the issue.


2. Created an SomeNameEndpoint.java file and generated a web service project from this.

  • Creates a web service project separate from my existing project.
  • Web Service seems to be synchronised in the virtual web server.
  • Right clicking to the home page for the web server results in the 404 error.
  • Looking at the localhost:8080 shows a running virtual web server page.

     package shlonline.integration.endpoints; import javax.jws.WebMethod; import javax.jws.WebService; import org.springframework.web.context.support.SpringBeanAutowiringSupport; @WebService(serviceName = "myServiceName") public class myServiceEndPoint extends SpringBeanAutowiringSupport { @WebMethod public boolean runWebMethod(String input) { return false; } } 

Problems:

  • Right clicking to the home page for the web server results in the 404 error.
  • Not sure how to debug the 404 error to determine the issue.

This tutorial along was really helpful for me, the project is available for github download, and uses maven and spring web services. It uses spring-ws with spring annotations of @Endpoint and @PayloadRoot annotations rather than the @WebService you have above.

http://briansjavablog.blogspot.com/2013/01/spring-web-services-tutorial.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM