cxf webservice 生成wsdl方法引數名稱為arg0問題

Gyoung發表於2016-05-13

在通過cxf生成webservice服務時,如果你是用ServerFactoryBean,那麼在生成wsdl時,方法的引數名稱會被自動命名為arg0,arg1...,如:

<xsd:complexType name="addPatientRegistry">
<xsd:sequence>
<xsd:element minOccurs="0" name="arg0" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="addPatientRegistryResponse" type="tns:addPatientRegistryResponse"/>

因為,java的反序列化沒辦法獲取引數名稱。

只能用JaxWsServerFactoryBean,但在在相應的介面上加註解@WebParam

@WebService
@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
public interface HelloService {
    String hello(@WebParam(name="name")String name);
}
 HelloService hw = new HelloServiceImpl();
        JaxWsServerFactoryBean jwsFactory = new JaxWsServerFactoryBean();
        jwsFactory.setAddress("http://10.0.1.32:5679/hello");   //指定WebService的釋出地址
        jwsFactory.setServiceClass(HelloService.class);//WebService對應的型別
        jwsFactory.setServiceBean(hw);//WebService對應的實現物件

        jwsFactory.create();

 

相關文章