我有wsdl文件,我用它生成java代码并在eclipse中实现web服务。
现在我的下一个任务是,我必须使用maven或任何东西生成包含所有tomcat jar依赖项的jar / war文件。
因此用户无需安装tomcat,他只需运行jar / war文件即可在某个端口使用这些Web服务。
如何实现呢?
有可能这样做吗?
请帮忙。
更多详情:
我尝试使用tomcat maven插件,按照以下链接提供的说明操作: http://maksim.sorokin.dk/it/2011/01/20/jax-ws-web-services-maven-tomcat/
它创建了war文件,但我无法访问这些soap端点。
<html><head><title>Apache Tomcat/7.0.47 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - /Project/services/SubscriberProvisioningService</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>/Project/services/SubscriberProvisioningService</u></p><p><b>description</b> <u>The requested resource is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.47</h3></body></html>
以下是配置完成:
IN POM.XML
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>default-cli</id>
<goals>
<goal>run</goal>
</goals>
<configuration>
<port>8080</port>
<path>/</path>
<useSeparateTomcatClassLoader>true</useSeparateTomcatClassLoader>
</configuration>
</execution>
</executions>
的beans.xml
<import resource="classpath:META-INF/cxf/cxf.xml" />
<jaxws:endpoint
id="SubscriberProvisioningService_PortType"
serviceName="s:SubscriberProvisioningService"
enpointName="e:SubscriberProvisioningService"
implementor="com.www.subscriber.SubscriberProvisioningService_BindingImpl"
address="http://localhost:8080/Project/services/SubscriberProvisioningService" xmlns:e="http://service.jaxws.cxf.apache.org/endpoint" xmlns:s="http://service.jaxws.cxf.apache.org/service"/>
使用以下命令运行:
mvn clean package -DskipTests=true tomcat7:run
[INFO] Packaging webapp
[INFO] Assembling webapp [Project] in [/home/projects/webservices/Project/target/Project-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/projects/webservices/Project/src/main/webapp]
[INFO] Webapp assembled in [115 msecs]
[INFO] Building war: /home/projects/webservices/Project/target/Project-0.0.1-SNAPSHOT.war
[INFO]
[INFO] >>> tomcat7-maven-plugin:2.2:run (default-cli) @ Project >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Project ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/projects/webservices/Project/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ Project ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< tomcat7-maven-plugin:2.2:run (default-cli) @ Project <<<
[INFO]
[INFO] --- tomcat7-maven-plugin:2.2:run (default-cli) @ Project ---
[INFO] Running war on http://localhost:8080/
[INFO] Creating Tomcat server configuration at /home/projects/webservices/Project/target/tomcat
[INFO] create webapp with contextPath:
答案 0 :(得分:0)
可能
如果要将tomcat用作Web容器,则要使用嵌入模式。也许这可以帮助: https://devcenter.heroku.com/articles/create-a-java-web-application-using-embedded-tomcat
还有tomcat的替代品,如码头,灰熊和底板。