Gob*_*ins 5 java soap web-services jetty jax-ws
我正在努力让一个肥皂网络服务在我的嵌入式码头服务器上运行。
我遵循了这个德语教程(ofc不起作用): http://www.torsten-horn.de/techdocs/jee-jax-ws.htm#Deployment-im-Webserver
相关代码片段:
Endpoint ep = Endpoint.publish( url, new BuecherServiceImpl() );
int anzahlBuecherResult = TestWsClient.test( "WsMitEndpointIntegrTest", url, 4000000000L, anzahlBuecher, true );
public static int test( String testName, String url, long startIsbn, int anzahlBuecher, boolean trace ) throws Exception
{
BuecherServiceIntf buecherService;
if( url.equalsIgnoreCase( "direkt" ) ) {
buecherService = new BuecherServiceImpl();
} else {
System.out.println( testName + ": " + url );
Service service = null;
int timeoutSekunden = 20;
while( service == null ) {
try {
//here the Exception occurs, maybe because of a wrong qname
service = Service.create(
new URL( url + "?wsdl" ),
new QName( "http://soap.apachecxf/" , "BuecherServiceImplService" ) );
} catch( WebServiceException ex ) {
if( timeoutSekunden-- <= 0 ) throw ex;
try { Thread.sleep( 1000 ); } catch( InterruptedException e ) {/*ok*/}
}
}
buecherService = service.getPort( BuecherServiceIntf.class );
}
Run Code Online (Sandbox Code Playgroud)
sun-jaxws.xml
<endpoints version="2.0" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime">
<endpoint name="BuecherService" implementation="soap.apachecxf.BuecherServiceImpl" url-pattern="/ws/BuecherService" />
</endpoints>
Run Code Online (Sandbox Code Playgroud)
有人可以在这里为我提供一些帮助吗?
小智 0
您可以通过覆盖默认的 HttpServerProvider 属性来运行带有嵌入式 jetty 的 SOAP Web 服务。确保您已在类路径上添加jetty-http-spi jar 文件
System.setProperty("com.sun.net.httpserver.HttpServerProvider", "org.eclipse.jetty.http.spi.JettyHttpServerProvider");
Run Code Online (Sandbox Code Playgroud)
org.eclipse.jetty.http.spi.JettyHttpServerProvider 是Jetty提供的Java HTTP Server SPI 的实现
您可以通过查看服务器响应标头来验证运行的服务器是否是 jetty。这段代码对我有用
public static void main(String[] args) throws Exception {
ContentWsImplement contentImplement = new ContentWsImplement();
System.setProperty("com.sun.net.httpserver.HttpServerProvider", "org.eclipse.jetty.http.spi.JettyHttpServerProvider");
Endpoint.publish("http://0.0.0.0:8000/services/getcontent", contentImplement);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4104 次 |
| 最近记录: |