简体   繁体   English

如何在Java,Maven和Spring中创建和测试SOAP和HTTP Web服务

[英]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. 本质上,我试图在Java,Maven和Spring中创建一个简单的SOAP Web服务。 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. 该项目是使用spring框架(主要是roo)创建的maven项目。
  • We're running the STS eclipse IDE which has a vmware (vSphere) virtual web server. 我们正在运行具有vmware(vSphere)虚拟Web服务器的STS eclipse IDE。

What I'm trying to achieve 我正在努力实现的目标

  • Add web services for SOAP and HTTP endpoints. 为SOAP和HTTP端点添加Web服务。
  • Have existing WSDLs for these web services. 具有用于这些Web服务的现有WSDL。

What I have tried: 我试过的

1. Creating a web service with "Top down Java bean Web Service" type pointing to the wsdl, VMware server. 1.使用“自上而下的Java bean Web服务”类型创建Web服务,该服务指向wsdl,VMware服务器。

  • Creates a web service project separate from my existing project. 与现有项目分开创建一个Web服务项目。
  • Web Service seems to be synchronised in the virtual web server. Web服务似乎在虚拟Web服务器中同步。
  • Right clicking to the home page for the web server results in the 404 error. 右键单击Web服务器的主页会导致404错误。
  • Looking at the localhost:8080 shows a running virtual web server page. 查看localhost:8080将显示正在运行的虚拟Web服务器页面。

Problems: 问题:

  • Project created is in the eclipse workspace rather than the source folders. 创建的项目位于Eclipse工作区中,而不是源文件夹中。 This results in source control commitment issues. 这导致源代码管理承诺问题。
  • Is it normal for all web services to be a separate project per web service in eclipse? 对于所有Web服务来说,在Eclipse中将每个Web服务作为一个单独的项目正常吗?
  • Right clicking to the home page for the web server results in the 404 error. 右键单击Web服务器的主页会导致404错误。
  • Not sure how to debug the 404 error to determine the issue. 不确定如何调试404错误以确定问题。


2. Created an SomeNameEndpoint.java file and generated a web service project from this. 2.创建一个SomeNameEndpoint.java文件,并由此生成一个Web服务项目。

  • Creates a web service project separate from my existing project. 与现有项目分开创建一个Web服务项目。
  • Web Service seems to be synchronised in the virtual web server. Web服务似乎在虚拟Web服务器中同步。
  • Right clicking to the home page for the web server results in the 404 error. 右键单击Web服务器的主页会导致404错误。
  • Looking at the localhost:8080 shows a running virtual web server page. 查看localhost:8080将显示正在运行的虚拟Web服务器页面。

     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. 右键单击Web服务器的主页会导致404错误。
  • Not sure how to debug the 404 error to determine the issue. 不确定如何调试404错误以确定问题。

This tutorial along was really helpful for me, the project is available for github download, and uses maven and spring web services. 本教程对我真的很有帮助,该项目可从github下载,并使用maven和spring Web服务。 It uses spring-ws with spring annotations of @Endpoint and @PayloadRoot annotations rather than the @WebService you have above. 它使用带有@Endpoint和@PayloadRoot批注的spring批注的spring-ws,而不是上面的@WebService。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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