客戶端動態調用cxf websevice 異常


三月 30, 2014 10:06:40 上午 org.apache.cxf.common.jaxb.JAXBUtils logGeneratedClassNames
信息: Created classes: com.test.server.HelloWorld, com.test.server.HelloWorldResponse, com.test.server.ObjectFactory
Exception in thread "main" org.apache.cxf.common.i18n.UncheckedException: No operation was found with the name {http://impl.server.test.com/}helloWorld.
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:342)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:336)
    at com.test.client.HelloWorl.main(HelloWorl.java:20)
Java Result: 1

解決方法:對服務端的接口實現類中的@WebService添加targetNamespace,其值為接口包名的倒置,

例如我的IHelloWorld接口所在的包為com.test.server,此時對應的targeNamespace的值為http://server.test.com/

例如:

@WebService(
        endpointInterface = "com.test.server.IHelloWorld", 
        serviceName="helloWorld", 
        targetNamespace="http://server.test.com/")
public class HelloWorldImp implements IHelloWorld {

    public String helloWorld(String name) {
        return name+" Hello,World!";
    }
    
}

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM