是否有一種框架,庫或技術將JAX-RS和JAX-WS(或等效功能)組合到一個組合服務中,類似於使用兩個端點(一個SOAP和一個REST)在WCF中的相同服務?組合JAX-RS和JAX-WS
11
A
回答
5
Apache CXF可以完成這項工作。閱讀更多在http://cxf.apache.org/docs/frontends.html
1
附加到米哈伊爾的答案,CXF的配置的例子。更多信息是http://cxf.apache.org/docs/jax-rs-and-jax-ws.html#JAX-RSandJAX-WS-JAXRSandJAXWS
<!-- JAX-RS -->
<jaxrs:server id="customerService" address="/">
<jaxrs:serviceBeans>
<ref bean="customerService" />
</jaxrs:serviceBeans>
</jaxrs:server>
<!-- JAX-WS -->
<jaxws:endpoint implementor="#customerService"
address="/CustomerWorld" wsdlLocation="..."/>
<bean id="customerService" class="demo.jaxrs.server.CustomerService" />
更新:彼得Szanto在https://github.com/ExampleDriven/cxf-example
2
有可能與標準的Tomcat配置創建一個Maven項目。只需爲服務使用單獨的URL。我決定把JAX-WS服務放在「SOAP /」後面,其他的放在小寫字母后面。如果你想在網址中使用「休息」,那就更簡單了,但對最終用戶來說並不好。別忘了添加一個sun-jaxws.xml。我留下了`init-params,因爲它們對於規範化的URL很有用。如果你願意,你可以放棄所有這些。
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="webapp"
version="2.5">
<display-name>displayname</display-name>
<filter>
<filter-name>rest</filter-name>
<filter-class>com.sun.jersey.spi.container.servlet.ServletContainer</filter-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>thepackage</param-value>
</init-param>
<init-param>
<!-- enables processing by JSPs if not JAX-RS handler is registered -->
<param-name>com.sun.jersey.config.feature.FilterForwardOn404</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.feature.CanonicalizeURIPath</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.feature.NormalizeURI</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.feature.Redirect</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>rest</filter-name>
<url-pattern>/firstresource/</url-pattern>
<url-pattern>/secondresource/</url-pattern>
</filter-mapping>
<listener>
<listener-class>
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>soap</servlet-name>
<servlet-class>
com.sun.xml.ws.transport.http.servlet.WSServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>soap</servlet-name>
<url-pattern>/SOAP</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>120</session-timeout>
</session-config>
</web-app>
相關問題
- 1. JAXWS和會話
- 2. JAXWS和ServiceMix的
- 3. XSD,JaxWS和Glassfish
- 4. jaxws-ri和jaxws-rt有什麼區別?
- 5. XmlInverseReference,Hibernate,JAXWS和Moxy
- 6. 如何使用JAXB和JAXRS
- 7. jaxws-maven-plugin和spring boot
- 8. 爲導入的XML Schema合併JAXB和JAXWS
- 9. 優化組合和組合
- 10. RPC /與JAXWS
- 11. Websphere中的JAXWS
- 12. JavaEE的CDI和注入@Provider JAXRS給UnsatisfiedDependencyException
- 13. 設置Swagger與Jaxrs日食和tomcat
- 14. JaxRs @cosume接受JSON和URL參數嗎?
- 15. JAXRS界面標記和@Context注射
- 16. 如何利用CXF,JAXRS和HTTP緩存
- 17. 關於JAXRS和tomee的基本查詢
- 18. 組合和合並
- 19. 無法找到XML名稱空間的Spring NamespaceHandler [http://cxf.apache.org/jaxws] - 包含cxf-rt-frontend-jaxrs
- 20. JAXRS異步服務
- 21. HTTP帖子在jaxrs
- 22. GlassFish v3.0.1中的JAXWS和Http Post超時
- 23. Netbeans 6.5和Glassfish V2上的jaxWS問題
- 24. Springboot jaxws(cxf)問題
- 25. 顯式加載jaxws
- 26. jaxws multple webservices single wsdl
- 27. JBoss上的JaxWS ClassCastException
- 28. jaxws-maven-plugin wsgen IllegalAnnotationExceptions
- 29. 組合和Li
- 30. 由幾個數組合並和組合