Hai Amila
I cannot give u my wsdl, did u try with a soap header with a single
element??
Code works fine with soap headers with multiple elements like
<level1>
<level2/>
</level1>
My suspect is soapHeaderBlockSource565.addChild(
omElementSource565.getFirstElement ());
if the omElementSource565 = <source>31231312321</source>
Are u sure like omElementSource565.getFirstElement () returns this
31231312321??
I am not sure about this anyways i dont know much about AXIOM
Thanks in advance
Mehar
On 8/1/07, Amila Suriarachchi <[EMAIL PROTECTED]> wrote:
>
> I wrote a sample service which uses the Headers and it worked fine.
>
> Can you please send your wsdl and Client?
>
> Amila.
>
> On 8/1/07, Mehar < [EMAIL PROTECTED]> wrote:
> >
> > Hai All,
> >
> > I have a wsdl with a singele service and many operations.
> >
> > The typical payload for an operation will look like this
> > <soapEnv:Envelope>
> >
> > <soapEnv:Header>
> > <sessonId>123123123141341</sessionId>
> > <source>32312312312312</source>
> >
> > <security>
> > <usernameToken>
> > <userName>afjlksdajflas</userName>
> > <password>fsdakljfaskljf</password>
> > </usernameToken>
> > </security>
> >
> > <soapEnv:Header>
> >
> > <soapEnv:Body>
> > </soapEnv:Body>
> >
> > </soapEnv:Envelope>
> >
> > wsdl fragments corrosponding to that are given here
> >
> > <wsdl:types>
> > <xsd:schema
> > targetNamespace="xxxx"
> > elementFormDefault="qualified">
> > <xsd:include schemaLocation="wsdl_types.xsd" />
> > <xsd:element name="sessionid" type="xsd:string" />
> > <xsd:element name="source" type="xsd:string" />
> > </xsd:schema>
> > </wsdl:types>
> >
> >
> > <!-- Message definitions -->
> > <wsdl:message name="session">
> > <wsdl:part name="sessionTokenHeader" element="types:sessionid"
> > />
> > </wsdl:message>
> >
> > <wsdl:message name="security">
> > <wsdl:part name="usernameTokenHeader" element="wsse:Security" />
> >
> > </wsdl:message>
> >
> > <wsdl:message name="source">
> > <wsdl:part name="sourceTokenHeader" element="types:source" />
> > </wsdl:message>
> >
> >
> > <wsdl:operation name="myoperation">
> > <wsdl:input>
> > <wsdlsoap:header message="tns:session"
> > part="sessionTokenHeader" use="literal" />
> > <wsdlsoap:header message="tns:security"
> > part="usernameTokenHeader" use="literal" />
> > <wsdlsoap:header message="tns:source"
> > part="sourceTokenHeader" use="literal" />
> > <wsdlsoap:body use="literal" />
> > </wsdl:input>
> > <wsdl:output>
> > <wsdlsoap:body use="literal" />
> > </wsdl:output>
> > <wsdl:fault name="fault">
> > <wsdlsoap:fault name="fault" use="literal" />
> > </wsdl:fault>
> > </wsdl:operation>
> >
> > The stub got generated has the following code to add the headers
> > // add the children only if the parameter is not null
> > if (sessionId563!=null){
> >
> >
> > org.apache.axiom.om.OMElement omElementsessionId563 = toOM(sessionId563,
> > optimizeContent(new javax.xml.namespace.QName ("xxxx", "myoperation")));
> >
> > org.apache.axiom.soap.SOAPHeaderBlock soapHeaderBlocksessionId563 =
> > env.getHeader().addHeaderBlock(omElementsessionId563.getLocalName (),
> > omElementsessionId563.getNamespace());
> >
> > soapHeaderBlocksessionId563.addChild(
> > omElementsessionId563.getFirstElement());
> >
> > }
> >
> > // add the children only if the
> > parameter is not null
> > if (security564!=null){
> >
> >
> > org.apache.axiom.om.OMElement omElementsecurity564 = toOM(security564,
> > optimizeContent(new javax.xml.namespace.QName("xxxx", "myoperation")));
> >
> > org.apache.axiom.soap.SOAPHeaderBlock soapHeaderBlocksecurity564 =
> > env.getHeader().addHeaderBlock(omElementsecurity564.getLocalName(),
> > omElementsecurity564.getNamespace ());
> >
> > soapHeaderBlocksecurity564.addChild(omElementsecurity564.getFirstElement
> > ());
> >
> > }
> >
> > // add the children only if the
> > parameter is not null
> > if (source565!=null){
> >
> >
> > org.apache.axiom.om.OMElement omElementSource565 = toOM(Source565,
> > optimizeContent(new javax.xml.namespace.QName("xxxxx", "myoperation")));
> >
> > org.apache.axiom.soap.SOAPHeaderBlock soapHeaderBlocksource565 =
> > env.getHeader().addHeaderBlock(omElementSource565.getLocalName(),
> > omElementSource565.getNamespace());
> >
> > soapHeaderBlockSource565.addChild(omElementSource565.getFirstElement());
> >
> > }
> >
> > If u look at the bold stuff results in a null pointer, here i will
> > explain how
> > omElementsource565 = <source>31234234213<source>
> > soapHeaderBlocksource565 =<soap/>
> > omElementSource565.getFirstElement() = null;
> > soapHeaderBlockSource565.addChild(omElementSource565.getFirstElement());
> > throws a null pointer....
> >
> > Is there something i am doing wrong is this a problem with the code
> > generation?
> > I am using axis2-1.3RC2, namespaces are omitted in the examle
> > Thanks in advance
> > --
> > Rgds
> > Mehar
> >
>
>
>
> --
> Amila Suriarachchi,
> WSO2 Inc.
--
Rgds
Mehar