如何在同一端口上托管SOAP服务和REST服务? [英] How to host a SOAP service and REST service at the same port?

查看:116
本文介绍了如何在同一端口上托管SOAP服务和REST服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何配置它,以便SOAP服务和REST服务可以在应用程序服务器外部使用Jersey(Grizzly)共享同一端口吗?

Does anyone know how to configure it so that a SOAP service and REST service can share the same port using Jersey (Grizzly) outside of an application server?

  • 我的肥皂服务位于www.someurl.com:port/soap/crm
  • 我的休息服务在www.someurl.com:port/crm

这些服务共享相同的端口,但不共享相同的基本url,因此它们应该能够在该端口上并排运行.但是,存在端口绑定错误..

These services share the same port but not the same base url and therefor should be able to run side by side on that port. However, there is a port bind error ..

所有这些都在自定义服务应用程序中,并且没有web.xml等.

All of this is in a custom service application and there is no web.xml or such.

REST服务正在使用Jersey,而Soap服务是在端点上发布的类'ReceptionService'.

The REST service is using Jersey and the Soap service is a class 'ReceptionService' published on an endpoint.

URI soapUri = URI.create("192.168.0.0:1234\soap\Crm")
URI restUri = URI.create("192.168.0.0:1234\crm")

// START SOAP SERVICE
Object reception = getObjectResource(ReceptionService.class);
Endpoint e = Endpoint.publish(soapUri, reception);

// START REST SERVICE    
ResourceConfig rc = new ResourceConfig().packages("company.rest");
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(restUri, rc);

当我尝试此操作时,Grizzly吐出"java.net.BindException:已在使用的地址:bind"

When I try this, Grizzly spits out 'java.net.BindException: Address already in use: bind'

我的肥皂服务接待设置如下:

My soap service reception is setup like this:

    @WebService(targetNamespace = "company.crm")
    @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL,      parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
    public class Reception implements ReceptionService {
     ... methods
    }

我的休息服务类像往常一样被注解...

My rest service classes are annotated as usual like ...

@Path("hello/{username}")
public class Hello { ... }

我在这方面还是个新手,任何指针都将不胜感激.并且,请不要打扰我运行应用程序服务器.这不是这里的问题-问题是如何解决端口绑定问题而不转移到其他Web服务框架?

I am a bit of a newbie at this and any pointers would be appreciated. And please, don't bother suggesting I run an application server. That is not the problem here -- the problem is how do I get around the port-bind issue without moving to some other webservice framework?

注意富饶:我无法重申这一点

NOTE RE BOUNTY: I CANNOT ITERATE THIS ENOUGH

赏金获得者将演示如何在同一端点上将Jersey用于REST和Java SOAP服务(带注释的JAX-WS)一起使用.答案不需要更改Rest和Soap带注释的类.但是,并且可以进行HTTP服务器代码更改或配置更改以使其正常运行.不接受切换到Jetty或其他应用程序服务器该解决方案必须100%嵌入并使用Java SE和Java Web服务库运行."

"The bounty winner will demonstrate how to use Jersey for REST and a Java SOAP service (annotated JAX-WS) together on the same endpoint. The answer will not require changes to the Rest and Soap annotated classes. However, and HTTP server code changes or configuration changes to make it work are acceptable. Switching to Jetty or some other application server are not acceptable The solution must be 100% embedded and run using Java SE and Java web service libraries."

推荐答案

Jetty的叠加功能允许您在同一Jetty实例/端口上部署具有不同路径的两个不同的Web应用程序.

Jetty's overlay feature allows you to deploy two different webapps with different paths on the same Jetty instance/port.

您的Jersey servlet(用于REST)将拥有一个web.xml,而SOAP servlet将具有另一个web.xml.

You would have one web.xml with your Jersey servlet (for REST) and the other web.xml with the SOAP servlet.

http://www.eclipse.org/jetty/documentation/current/overlay-deployer.html

这篇关于如何在同一端口上托管SOAP服务和REST服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆