Hello,
I generate client code out of a wsdl with axis2 (v. 1.2) wsdl2java and
jaxbri(v. 2.0.2) databinding.
the wsdl not only defines request and reply messages but also the header
element of the soap message.
i have the following problems with the generated code:
1) The generated code for the client stub doesn't compile because of a
parameter error in the "toOM"-Method for the Header.
2) When i fix the error, the invocation of "toOM" fails because of incorrect/
missing values when creating the OMElement for the Header
3) When i fix this error too by filling in the correct values for the
HeaderType, the client code works.
I think the wsdl is correct because generated code with adb binding out of this
wsdl works fine.
It seems that axis2 code generation doesn't generate correct code with jaxb
binding when you have defined a soap header in the wsdl.
Does someone have a similiar problem (or fixed it)?
greetings from sunny munich :)
andi
some code snippets from the generated stub:
"toOM"-Method call. "mMS150_Display0" represents the request data type, "mws1"
the header data type.
1)--
**snip**
env = toEnvelope(getFactory(
_operationClient.getOptions().getSoapVersionURI()),
mMS150_Display0,
optimizeContent(new javax.xml.namespace.QName("", "MMS150_Display")));
env.build();
// add the children only if the parameter is not null
if (mws1!=null){
env.getHeader().addChild(
toOM(mws1, optimizeContent(new javax.xml.namespace.QName("",
"MMS150_Display";
}
**snap**
"toOM"-Method for the header:
2)--
**snip**
private org.apache.axiom.om.OMElement toOM(net.company.mws.mws2.HeaderType
param, org.apache.axiom.soap.SOAPFactory factory, boolean optimizeContent) {
try {
javax.xml.bind.JAXBContext context = net_company_mws_mws2_HeaderType;
javax.xml.bind.Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FRAGMENT,
Boolean.TRUE);
JaxbRIDataSource source = new JaxbRIDataSource(
net.company.mws.mws2.HeaderType.class,
param,
marshaller,
"",
"");
org.apache.axiom.om.OMNamespace namespace =
factory.createOMNamespace("",
null);
return factory.createOMElement(source, "", namespace);
} catch (javax.xml.bind.JAXBException bex){
throw new RuntimeException(bex);
}
}
**snap**
the call of the "toOM"-Method (with Parameters HeaderType, boolean) doesn't fit
with the signature of the toOm-Method (HeaderType, SOAPFactory, boolean)
i can correct this error by adding
"getFactory(_operationClient.getOptions().getSoapVersionURI())" to the
toOM-Method call in the generated stub.
then i run into the second error i mentioned above.
The following code snippet shows the correct values for in the "toOM"-Method:
3)--
**snip**
JaxbRIDataSource source = new JaxbRIDataSource(
net.company.mws.mws2.HeaderType.class,
param,
marshaller,
"http://mws.company.net/mws2";,
"mws");
org.apache.axiom.om.OMNamespace namespace = factory.createOMNamespace("",
null);
return factory.createOMElement(source, "mws", namespace);
**snap**
the wsdl:
--
**snip**
http://schemas.xmlsoap.org/wsdl/";
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
xmlns:mws="http://mws.company.net/mws2";
xmlns:tns="http://schemas.company.com/KKTEST2";
xmlns:mms150_display="http://schemas.company.com/KKTEST2/MMS150_Display";
name="KKTEST2" targetNamespace="http://schemas.company.com/KKTEST2";>
http://www.w3.org/2001/XMLSchema";
targetNamespace="http://schemas.company.com/KKTEST2/MMS150_Display";
elementFormDefault="qualified">
http://www.w3.org/2001/XMLSchema";
xmlns:tns="http://mws.company.net/mws2";
targetNamespace="http://mws.company.net/mws2";
elementFormDefault="qualified">