cxf

cxf入门和练习

雨燕双飞 提交于 2020-01-09 00:59:27
一、什么是cxf Apache CXF=Celtix+Xfire 支持多种协议: 1)SOAP1.1,1.2 2)HTTP 3)可以与spring进行快速无缝整合 4)灵活部署:可以运行有tomcat,JBoss,Jetty(内置),IBMWS上面。 二、环境搭建 1)JAVA_HOME,需要jdk的支持 2)CXF_HOME 三、实现cxf第一个示例 1、创建java项目 2、引入所有依赖的包 3、创建服务类: 用两个不同的类发布应用: ServerFactoryBean(不需要使用@WebService),但是生产的文档不规范,不建议使用; JaxWsServerFactoryBean(建议使用此类,需要使用@WebService),生产的文档规范,可以发布SOAP1.1,SOAP1.2的协议,当cxf的服务类中没有方法也可以发布,不报错。如果使用SOAP1.2需要使用@binType注解指定 当使用SOAP1.2时wsimport命令失效,需要使用cxf的wsdl2java. 建议:发布服务的时候使用SOAP1.2,客户端调用的时候使用wsdl2java. @WebService @BindingType(value=javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING) public class HelloService {

How to add Basic Authorization to a wsdl on startup with cxf?

非 Y 不嫁゛ 提交于 2020-01-07 03:10:09
问题 I have a wsdl client and autogenerated classes with cxf . The wsdl's themselves require basic authorization to be accessd, thus I add the following to each BindingPort : Map<String, Object> requestContext = ((BindingProvider)sc).getRequestContext(); requestContext.put(BindingProvider.USERNAME_PROPERTY, userName); requestContext.put(BindingProvider.PASSWORD_PROPERTY, password); Problem: the evaluates first when running the webservice client. But before that, cxf is trying to initialize the

CXF log SOAP output

青春壹個敷衍的年華 提交于 2020-01-06 20:06:48
问题 I am having trouble logging an outgoing SOAP message from the server. The handleMessage method does not overwrite the message content as expected. How would I store the outgoing SOAP to the message? public class OutgoingSoapInterceptor extends AbstractPhaseInterceptor<Message> { private static final Logger logger = LoggerFactory.getLogger(OutgoingSoapInterceptor.class.getName()); public OutgoingSoapInterceptor () { super(Phase.PRE_STREAM); } @Override public void handleMessage(Message message

How to get the configured HTTP and HTTPS port numbers in server.xml from Java code at runtime

自古美人都是妖i 提交于 2020-01-06 18:04:03
问题 In our project, we have implemented SOAP webservices using Apache CXF framework. Clients used to request the server for some command execution. The request consists of host, port and the protocol used for connection. If the client uses a HTTPS configured port number and specify the protocol as HTTP, then we get a connection refused - socket exception as expected. But, I need to throw a proper error message like "Unable to connect to host "XYZ" with port "ABC" using http protocol". For this, I

ERROR during invoking WebService - could not initialize proxy - no Session

被刻印的时光 ゝ 提交于 2020-01-06 16:55:07
问题 Application: Spring + Hibernate + Apache CXF - idea simple say hello service which is taking one param - id of object in database and return text "Hello: " + person.getName(); Here are some code: @Entity public class Person { @Id @GeneratedValue(strategy=GenerationType.AUTO) private long id; private String login; private String email; //getters and setters } PersonDAO: public interface PersonDAO { public void savePerson(Person person); public Person getPerson(long id); } PersonDAOImpl:

ERROR during invoking WebService - could not initialize proxy - no Session

眉间皱痕 提交于 2020-01-06 16:54:33
问题 Application: Spring + Hibernate + Apache CXF - idea simple say hello service which is taking one param - id of object in database and return text "Hello: " + person.getName(); Here are some code: @Entity public class Person { @Id @GeneratedValue(strategy=GenerationType.AUTO) private long id; private String login; private String email; //getters and setters } PersonDAO: public interface PersonDAO { public void savePerson(Person person); public Person getPerson(long id); } PersonDAOImpl:

Need to create a jar out of the web service client files

别说谁变了你拦得住时间么 提交于 2020-01-06 03:53:10
问题 I have the WSDL file for a JAX-WS web service. I have created a maven-archetype-quickstart project(simple java project) and imported it to Eclipse Kepler workspace using import->existing maven project. I copied the wsdl file to the project's src/main/resources folder(created resources newly). I generated the web service client using the maven plugin <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-codegen-plugin</artifactId> <version>2.7.11</version> <executions> <execution> <id

Create webservice on Android device with cxf?

核能气质少年 提交于 2020-01-06 02:28:25
问题 I was able to create webservice in desktop java using Apache CXF. However i need it to working on Android device. The problem is that java.ws package is absent in Android. I've copied all required jar with java.ws classes into libs folder of android project , but while dexing (building of the app in IDE) i'm having the next errors: Error:Android Pre Dex: [android-ws-combine.jar] trouble processing "javax/xml/bind/Binder.class": Error:Android Pre Dex: [android-ws-combine.jar] Ill-advised or

Create webservice on Android device with cxf?

吃可爱长大的小学妹 提交于 2020-01-06 02:28:08
问题 I was able to create webservice in desktop java using Apache CXF. However i need it to working on Android device. The problem is that java.ws package is absent in Android. I've copied all required jar with java.ws classes into libs folder of android project , but while dexing (building of the app in IDE) i'm having the next errors: Error:Android Pre Dex: [android-ws-combine.jar] trouble processing "javax/xml/bind/Binder.class": Error:Android Pre Dex: [android-ws-combine.jar] Ill-advised or

Sharing data between CXF interceptor and webservice

谁都会走 提交于 2020-01-06 02:20:08
问题 I'm using security interceptors with Apache CXF WSS4JInInterceptor . Is there any way to pass data from interceptor to webservice? I've been searching for that in WebServiceContext but I can't find it. 回答1: You can use the CXF Exchange Map to store arbitrary key/value pairs. The Exchange is available to both input and output messages. In your interceptor, add the object to the Exchange, e.g. Object value = ...; message.getExchange().put("key", value); Within your service, you can use