[英]How to generate a web service from a WSDL
I know this question has been asked a few times, but I checked the stackoverflow history/questions and it does not quite answer what I am trying to do. 我知道这个问题已被问过几次,但是我检查了stackoverflow的历史/问题,并没有完全回答我想要做的事情。 I have a WSDL. 我有一个WSDL。 I want to generate a web service for that WSDL. 我想为该WSDL生成一个Web服务。 I know that I have to manually write something, but that's the part I need help. 我知道我必须手动写一些东西,但那是我需要帮助的部分。
I have a WSDL. 我有一个WSDL。 I save it in /home/username/java/ws/wsdl/test.wsdl. 我将它保存在/home/username/java/ws/wsdl/test.wsdl中。 I also have an xsd at /home/username/java/ws/wsdl/test.xsd used by the aforementioned WSDL. 我在前面提到的WSDL使用的/home/username/java/ws/wsdl/test.xsd上也有一个xsd。
I generate the server stubs for this like so: 我为此生成服务器存根,如下所示:
[/home/username/java/ws/wsdl/] $ wsimport -p com.uptimeservice.ws -d build/classes -s src wsdl/test.wsdl
Now, I need an implementor. 现在,我需要一个实现者。 I create one like so under /home/username/java/ws/src/WsImpl.java: 我在/home/username/java/ws/src/WsImpl.java下创建了一个这样的:
package com.uptimeservice;
import javax.jws.WebService;
import com.uptimeservice.ws.*;
@WebService(name = "UptimeService",
targetNamespace = "test",
serviceName = "UptimeService",
portName = "UptimeServiceSOAP",
endpointInterface = "com.uptimeservice.ws.UptimeService",
wsdlLocation = "/home/username/java/ws/wsdl/test.wsdl")
public class WsImpl implements UptimeService {
@Override
public UptimeResponseType uptimeRequest(UptimeRequestType msg) {
UptimeResponseType resp = null;
return resp;
}
}
I compile it like so: [/home/username/java/ws/src/] $ javac -classpath /home/username/java/ws/build/classes/:. 我这样编译:[/ home / username / java / ws / src /] $ javac -classpath / home / username / java / ws / build / classes /:。 com/uptimeservice/WsImpl.java COM / uptimeservice / WsImpl.java
Then when I try to deploy the service, like so: /home/username/java/ws/src/] $ java -classpath /home/username/java/ws/build/classes/:. 然后,当我尝试部署服务时,如下所示:/ home / username / java / ws / src /] $ java -classpath / home / username / java / ws / build / classes /:。 com/uptimeservice/WsImpl COM / uptimeservice / WsImpl
I get the error: Exception in thread "main" java.lang.NoSuchMethodError: main 我得到错误:线程“main”中的异常java.lang.NoSuchMethodError:main
My guess is that this is something very trivial, but I am not a Java person. 我的猜测是,这是非常微不足道的,但我不是一个Java人。
Any help is appreciated. 任何帮助表示赞赏。
Thanks! 谢谢!
Generally a webservice will be installed on a java web server, such as Tomcat, Jboss, Jetty, Websphere, in a war file. 通常,web服务将安装在war web文件中的Java Web服务器上,例如Tomcat,Jboss,Jetty,Websphere。
You are trying to run it manually, as a standalone application, and all standalone applications need a main function called main
, just as C or C#, for example. 您尝试手动运行它,作为独立应用程序,并且所有独立应用程序都需要一个名为main
的主函数,例如C或C#。
So, how are you actually going to deploy this, on a webserver or as a standalone application? 那么,您实际上如何在Web服务器上或作为独立应用程序进行部署?
If you do it as a standalone application then you will need an embedded http server, btw. 如果你作为一个独立的应用程序,那么你将需要一个嵌入式http服务器,顺便说一句。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.