1

我想通过 CXF Jax-ws 发送一个 org.apache.cxf.message.Message 对象。例如:

  1. 一项服务声明:

    @WebService
    public interface HelloWorld {
        void send(Message msg);
    }
    
  2. 该服务的实现:

    public class HelloWorldImpl implements HelloWorld {
        public void send(Message msg) {
            System.out.println("receives msg id:" +((MessageImpl)msg).getId());
        }
    }
    
  3. 服务器:

    HelloWorldImpl implementor = new HelloWorldImpl();
    JaxWsServerFactoryBean svrFactory1 = new JaxWsServerFactoryBean();
    svrFactory1.setServiceClass(HelloWorld.class);
    svrFactory1.setAddress("http://192.168.56.1:9000/HelloWorld");
    svrFactory1.setServiceBean(implementor);
    org.apache.cxf.endpoint.Server server1 = svrFactory1.create();
    server1.start();
    
  4. 客户:

    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setAddress("http://192.168.56.1:9000/HelloWorld");
    HelloWorld client = factory.create(HelloWorld.class);
    Message msg = new MessageImpl();
    msg.setId("abc");
    client.send(msg);
    

运行时收到如下错误:

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Fault occurred while processing.
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:160)
at com.sun.proxy.$Proxy37.sayHiToUser(Unknown Source)
at objecttype.Client.main(Client.java:60)


Caused by: org.apache.cxf.binding.soap.SoapFault: Fault occurred while processing.
.......

如何纠正这个错误?

问候,

4

0 回答 0