Getting rid of <arg0>

I have Java WebService code in my eclipse. I used @WebService @Webmethod, @XmlElements, @XmlType, @XmlAccessorType

Now I am creating wsdl using the java2ws command from the cxf framework. Here is the command

F:\....\code\java2wsdl>java2ws -o CustomerVxRR.wsdl -d <myOutputDir> -wsdl -cp <myClassesFolder> <ServiceImpl class> 

my wsdl file contqins agr0 as a name that I don't want, because when I import it into SoapUI. It adds a tag around the field.

Here is the wsdl part with arg0

 <xs:schema ..... > <xs:complexType name="myServiceMethodName"> <xs:sequence> <xs:element minOccurs="0" name="arg0" type="tns:ServiceInputClassName"/> </xs:sequence> </xs:complexType> <xs:complexType name="ServiceInputClassName"> <xs:sequence> <xs:element minOccurs="0" name="EmpID" type="xs:string"/> </xs:sequence> </xs:complexType> </xz:schema> 

Here is the request object that is created in SOAPUI

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cus="http://customeroffer.manage.ws.hello.my.com/"> <soapenv:Header/> <soapenv:Body> <cus:myServiceMethodName> <!--Optional:--> <arg0> <EmpID >123456</EmpID> </arg0> </cus:myServiceMethodName> </soapenv:Body> </soapenv:Envelope> 

If I remove the tag, I get this answer:

 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <soap:Fault> <faultcode>soap:Client</faultcode> <faultstring>Unmarshalling Error: unexpected element (uri:"", local:"EmpID"). Expected elements are &lt;{}empid></faultstring> </soap:Fault> </soap:Body> </soap:Envelope> 

I do not want to contain arg0 in the XML request

+6
source share
1 answer

I just fixed it after doing some research on my own code. The only thing required to change <arg0> is that we need to use the @WebParam annotation to declare the name custome instead of "arg0".

For instance:

my service name is getEmpDetail and EmpID is the input parameter for the service, and here is the declaration required for the service impl class:

 public Emp getEmpDetail(@WebParam(name="EmpDetail") String EmpId) 

after generating from WSDL, the XML request will look below

 <ns:getEmpDetail> <EmpDetail> <EmdID>?</EmpID> </EmpDetail> <ns:getEmpDetail> 
+11
source

All Articles