You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Ivan <xh...@gmail.com> on 2011/04/11 09:58:05 UTC

SOAPMessage.getSOAPHeaders() return null while no headers in the soap envelope

Hi, I am running Axis2 on Geronimo 3.0, and in the latest JAX-WS TCK
testing, I got a NPE for some cases. The cause for it is that some cases
will check whether those elements are not in the SOAP headers, while those
soap message has no header element.
>From the Java doc of SOAPMessage, it writes :
getSOAPHeader

public SOAPHeader </j2ee6/api/javax/xml/soap/SOAPHeader.html> *getSOAPHeader*()
                         throws SOAPException
</j2ee6/api/javax/xml/soap/SOAPException.html>

Gets the SOAP Header contained in this SOAPMessage object.

 *Returns:* the SOAPHeader object contained by this SOAPMessage object *
Throws:* SOAPException - if the SOAP Header does not exist or cannot be
retrieved *Since:* SAAJ 1.2
>From the Java Doc of SOAPEnvelop, it wirtes:
getHeader

SOAPHeader </j2ee6/api/javax/xml/soap/SOAPHeader.html> *getHeader*()
                     throws SOAPException
</j2ee6/api/javax/xml/soap/SOAPException.html>

Returns the SOAPHeader object for this SOAPEnvelope object.

A new SOAPMessage object is by default created with a SOAPEnvelope object
that contains an empty SOAPHeader object. As a result, the method
getHeaderwill always return a
SOAPHeader object unless the header has been removed and a new one has not
been added.
 *Returns:* the SOAPHeader object or null if there is none *Throws:*
SOAPException - if there is a problem obtaining the SOAPHeader object
It seems that there is different behavior for SOAPMessage.getSOAPHeader()
and SOAPEnvelop.getHeader(). and in current axis2-saaj implementation, it
always returns null while no header element exists.
Personally, I thought it is an issue of saaj spec, it is not user-friendly
to throw an exception while no header exists. Actually, I also test this
with the ri saaj implementation, and it seems to have the same behavior with
axis2-saaj.
Another possible solution is to add an empty header element for those soap
message if no header element exists, I could see it could be done in the
SAAJConverter.

Thoughts ?
thanks.
-- 
Ivan

Re: Query database in Axis2

Posted by Deepal Jayasinghe <de...@opensource.lk>.
Create a service class with some Java beans and return a Java bean as
the return type. So that you can populate it with the values you want
(probably getting from resultSet). You can also have a look at the
following article:

http://www.developer.com/db/article.php/3735771/Exposing-a-Database-as-a-Web-Service.htm

Deepal
>
> Hey Dev,
>
>  
>
> I am using Eclipse Galileo, apache tomcat 5.5, Axis2.
>
>  
>
> I have been looking everywhere and couldn't figure out.
>
>  
>
> 1.       I want to fetch data from database(mysql).What is the best
> approach(suggest).Please give me a sample if you have.
>
> 2.       I have used ArrayList for it so now the soap result I get:
>
> Soap Request
>
> *-*
> <http://127.0.0.1:49607/wse/wsdl/soap_envelope_xml.jsp?soapEnvelopeType=0>
> <soapenv:Envelopexmlns:soapenv="*http://schemas.xmlsoap.org/soap/envelope/*"xmlns:q0="*http://sdsdd*"   xmlns:xsd="*http://www.w3.org/2001/XMLSchema*"xmlns:xsi="*http://www.w3.org/2001/XMLSchema-instance*">
>
> *-*
> <http://127.0.0.1:49607/wse/wsdl/soap_envelope_xml.jsp?soapEnvelopeType=0>
> <           <soapenv:Body>
>
> *-*
> <http://127.0.0.1:49607/wse/wsdl/soap_envelope_xml.jsp?soapEnvelopeType=0>
> <           <q0:res>
>
>  <           <q0:group>application</q0:group>
>
>         </q0:res>
>
>         </soapenv:Body>
>
> 3.*-*
> <http://127.0.0.1:49607/wse/wsdl/soap_envelope_xml.jsp?soapEnvelopeType=0>
> <q0:res>
>
> 4.* *<q0:group>*application*</q0:group>
>
> 5.* *</q0:res>
>
> 6.* *</soapenv:Body>
>
> </soapenv:Envelope>
>
>  
>
> Response:
>
> *-*
> <http://127.0.0.1:49607/wse/wsdl/soap_envelope_xml.jsp?soapEnvelopeType=1>
> <soapenv:Envelopexmlns:soapenv="*http://schemas.xmlsoap.org/soap/envelope/*">
>
> *-*
> <http://127.0.0.1:49607/wse/wsdl/soap_envelope_xml.jsp?soapEnvelopeType=1>
> <soapenv:Body>
>
> *-*
> <http://127.0.0.1:49607/wse/wsdl/soap_envelope_xml.jsp?soapEnvelopeType=1>
> <ns:resResponsexmlns:ns="*http://sdsdd*">
>
> * *<ns:return>*1*</ns:return>
>
> * *<ns:return>*Swetta*</ns:return>
>
> * *<ns:return>*Application*</ns:return>
>
> * *<ns:return>*4*</ns:return>
>
> * *<ns:return>*riys*</ns:return>
>
> * *<ns:return>*Application*</ns:return>
>
> * *<ns:return>*5*</ns:return>
>
> * *<ns:return>*riva*</ns:return>
>
> * *<ns:return>*application*</ns:return>
>
> * *<ns:return>*6*</ns:return>
>
> * *<ns:return>*uiyrur*</ns:return>
>
> * *<ns:return>*application*</ns:return>
>
> * *<ns:return>*7*</ns:return>
>
> * *<ns:return>*rahul*</ns:return>
>
> * *<ns:return>*application*</ns:return>
>
> * *<ns:return>*8*</ns:return>
>
> * *<ns:return>*rita*</ns:return>
>
> * *<ns:return>*application*</ns:return>
>
> * *<ns:return>*9*</ns:return>
>
> * *<ns:return>*rima*</ns:return>
>
> * *<ns:return>*application*</ns:return>
>
> * *</ns:resResponse>
>
> * *</soapenv:Body>
>
> * *</soapenv:Envelope>
>
>  
>
> In reponse Element is <ns:return> rather that it should be
> <id>,<name>, etc. How do I do that.
>
> 3. Just wanted to confirm that whatever is the return from a function
> is what is generated in wsdl.
>
> 4.How can wsdl which is generated at run time be edited.
>
>  
>
> Appreciate your help. Thank you so much.
>
>  
>
>  
>
> *Swetta Bhaskar*
>
>  
>
>  
>
> *From:*Ivan [mailto:xhhsld@gmail.com]
> *Sent:* Tuesday, April 12, 2011 2:44 AM
> *To:* java-user@axis.apache.org; dev@geronimo.apache.org
> *Subject:* Re: SOAPMessage.getSOAPHeaders() return null while no
> headers in the soap envelope
>
>  
>
> Open a JIRA https://issues.apache.org/jira/browse/AXIS2-5001 for this
>
> 2011/4/12 Andreas Veithen <andreas.veithen@gmail.com
> <ma...@gmail.com>>
>
> Ivan,
>
> Based on your description of the problem it is not possible to
> determine if that should be considered an issue in Axiom, axis2-saaj
> or axis2-jaxws. Please open a JIRA report and submit a test case that
> allows to reproduce the issue so that we can determine where this
> needs to be fixed.
>
> Andreas
>
>
> On Mon, Apr 11, 2011 at 10:41, Ivan <xhhsld@gmail.com
> <ma...@gmail.com>> wrote:
> > Seems that axiom optimize the serialization, if no sub header element
> > exists, it will not output header element.
> > --->
> > if ((header != null) && (header.getFirstOMChild() != null)) {
> >                     serializeInternally((OMNodeImpl) header, writer);
> >                 }
> > <---
> >
> > 2011/4/11 Ivan <xhhsld@gmail.com <ma...@gmail.com>>
> >>
> >> Hi, I am running Axis2 on Geronimo 3.0, and in the latest JAX-WS TCK
> >> testing, I got a NPE for some cases. The cause for it is that some
> cases
> >> will check whether those elements are not in the SOAP headers,
> while those
> >> soap message has no header element.
> >> From the Java doc of SOAPMessage, it writes :
> >>
> >> getSOAPHeader
> >>
> >> public SOAPHeader getSOAPHeader()
> >>                          throws SOAPException
> >>
> >> Gets the SOAP Header contained in this SOAPMessage object.
> >>
> >> Returns: the SOAPHeader object contained by this SOAPMessage object
> >> Throws: SOAPException - if the SOAP Header does not exist or cannot be
> >> retrieved Since: SAAJ 1.2
> >> From the Java Doc of SOAPEnvelop, it wirtes:
> >>
> >> getHeader
> >>
> >> SOAPHeader getHeader()
> >>                      throws SOAPException
> >>
> >> Returns the SOAPHeader object for this SOAPEnvelope object.
> >>
> >> A new SOAPMessage object is by default created with a SOAPEnvelope
> object
> >> that contains an empty SOAPHeader object. As a result, the method
> getHeader
> >> will always return a SOAPHeader object unless the header has been
> removed
> >> and a new one has not been added.
> >>
> >> Returns: the SOAPHeader object or null if there is none Throws:
> >> SOAPException - if there is a problem obtaining the SOAPHeader object
> >> It seems that there is different behavior for
> SOAPMessage.getSOAPHeader()
> >> and SOAPEnvelop.getHeader(). and in current axis2-saaj
> implementation, it
> >> always returns null while no header element exists.
> >> Personally, I thought it is an issue of saaj spec, it is not
> user-friendly
> >> to throw an exception while no header exists. Actually, I also test
> this
> >> with the ri saaj implementation, and it seems to have the same
> behavior with
> >> axis2-saaj.
> >> Another possible solution is to add an empty header element for
> those soap
> >> message if no header element exists, I could see it could be done
> in the
> >> SAAJConverter.
> >>
> >> Thoughts ?
> >> thanks.
> >> --
> >> Ivan
> >
> >
> >
> > --
> > Ivan
> >
>
>
>
>
> -- 
> Ivan
>

Query database in Axis2

Posted by Swetta Bhaskar <sb...@csidentity.com>.
Hey Dev,

 

I am using Eclipse Galileo, apache tomcat 5.5, Axis2.

 

I have been looking everywhere and couldn't figure out.

 

1.       I want to fetch data from database(mysql).What is the best
approach(suggest).Please give me a sample if you have.

2.       I have used ArrayList for it so now the soap result I get:

Soap Request

-
<http://127.0.0.1:49607/wse/wsdl/soap_envelope_xml.jsp?soapEnvelopeType=
0>  <soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:q0="http://sdsdd"    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

-
<http://127.0.0.1:49607/wse/wsdl/soap_envelope_xml.jsp?soapEnvelopeType=
0>  <           <soapenv:Body>

-
<http://127.0.0.1:49607/wse/wsdl/soap_envelope_xml.jsp?soapEnvelopeType=
0>  <           <q0:res>

  <           <q0:group>application</q0:group> 

        </q0:res>

        </soapenv:Body>

3. -
<http://127.0.0.1:49607/wse/wsdl/soap_envelope_xml.jsp?soapEnvelopeType=
0>  <q0:res>

4.  <q0:group>application</q0:group> 

5.  </q0:res>

6.  </soapenv:Body>

</soapenv:Envelope>

 

Response:

-
<http://127.0.0.1:49607/wse/wsdl/soap_envelope_xml.jsp?soapEnvelopeType=
1>  <soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

-
<http://127.0.0.1:49607/wse/wsdl/soap_envelope_xml.jsp?soapEnvelopeType=
1>  <soapenv:Body>

-
<http://127.0.0.1:49607/wse/wsdl/soap_envelope_xml.jsp?soapEnvelopeType=
1>  <ns:resResponse xmlns:ns="http://sdsdd">

  <ns:return>1</ns:return> 

  <ns:return>Swetta</ns:return> 

  <ns:return>Application</ns:return> 

  <ns:return>4</ns:return> 

  <ns:return>riys</ns:return> 

  <ns:return>Application</ns:return> 

  <ns:return>5</ns:return> 

  <ns:return>riva</ns:return> 

  <ns:return>application</ns:return> 

  <ns:return>6</ns:return> 

  <ns:return>uiyrur</ns:return> 

  <ns:return>application</ns:return> 

  <ns:return>7</ns:return> 

  <ns:return>rahul</ns:return> 

  <ns:return>application</ns:return> 

  <ns:return>8</ns:return> 

  <ns:return>rita</ns:return> 

  <ns:return>application</ns:return> 

  <ns:return>9</ns:return> 

  <ns:return>rima</ns:return> 

  <ns:return>application</ns:return> 

  </ns:resResponse>

  </soapenv:Body>

  </soapenv:Envelope>

 

In reponse Element is <ns:return> rather that it should be <id>,<name>,
etc. How do I do that. 

3. Just wanted to confirm that whatever is the return from a function is
what is generated in wsdl.

4.How can wsdl which is generated at run time be edited.

 

Appreciate your help. Thank you so much.

 

 

Swetta Bhaskar

 

 

From: Ivan [mailto:xhhsld@gmail.com] 
Sent: Tuesday, April 12, 2011 2:44 AM
To: java-user@axis.apache.org; dev@geronimo.apache.org
Subject: Re: SOAPMessage.getSOAPHeaders() return null while no headers
in the soap envelope

 

Open a JIRA https://issues.apache.org/jira/browse/AXIS2-5001 for this

2011/4/12 Andreas Veithen <an...@gmail.com>

Ivan,

Based on your description of the problem it is not possible to
determine if that should be considered an issue in Axiom, axis2-saaj
or axis2-jaxws. Please open a JIRA report and submit a test case that
allows to reproduce the issue so that we can determine where this
needs to be fixed.

Andreas


On Mon, Apr 11, 2011 at 10:41, Ivan <xh...@gmail.com> wrote:
> Seems that axiom optimize the serialization, if no sub header element
> exists, it will not output header element.
> --->
> if ((header != null) && (header.getFirstOMChild() != null)) {
>                     serializeInternally((OMNodeImpl) header, writer);
>                 }
> <---
>
> 2011/4/11 Ivan <xh...@gmail.com>
>>
>> Hi, I am running Axis2 on Geronimo 3.0, and in the latest JAX-WS TCK
>> testing, I got a NPE for some cases. The cause for it is that some
cases
>> will check whether those elements are not in the SOAP headers, while
those
>> soap message has no header element.
>> From the Java doc of SOAPMessage, it writes :
>>
>> getSOAPHeader
>>
>> public SOAPHeader getSOAPHeader()
>>                          throws SOAPException
>>
>> Gets the SOAP Header contained in this SOAPMessage object.
>>
>> Returns: the SOAPHeader object contained by this SOAPMessage object
>> Throws: SOAPException - if the SOAP Header does not exist or cannot
be
>> retrieved Since: SAAJ 1.2
>> From the Java Doc of SOAPEnvelop, it wirtes:
>>
>> getHeader
>>
>> SOAPHeader getHeader()
>>                      throws SOAPException
>>
>> Returns the SOAPHeader object for this SOAPEnvelope object.
>>
>> A new SOAPMessage object is by default created with a SOAPEnvelope
object
>> that contains an empty SOAPHeader object. As a result, the method
getHeader
>> will always return a SOAPHeader object unless the header has been
removed
>> and a new one has not been added.
>>
>> Returns: the SOAPHeader object or null if there is none Throws:
>> SOAPException - if there is a problem obtaining the SOAPHeader object
>> It seems that there is different behavior for
SOAPMessage.getSOAPHeader()
>> and SOAPEnvelop.getHeader(). and in current axis2-saaj
implementation, it
>> always returns null while no header element exists.
>> Personally, I thought it is an issue of saaj spec, it is not
user-friendly
>> to throw an exception while no header exists. Actually, I also test
this
>> with the ri saaj implementation, and it seems to have the same
behavior with
>> axis2-saaj.
>> Another possible solution is to add an empty header element for those
soap
>> message if no header element exists, I could see it could be done in
the
>> SAAJConverter.
>>
>> Thoughts ?
>> thanks.
>> --
>> Ivan
>
>
>
> --
> Ivan
>




-- 
Ivan


Re: SOAPMessage.getSOAPHeaders() return null while no headers in the soap envelope

Posted by Ivan <xh...@gmail.com>.
Open a JIRA https://issues.apache.org/jira/browse/AXIS2-5001 for this

2011/4/12 Andreas Veithen <an...@gmail.com>

> Ivan,
>
> Based on your description of the problem it is not possible to
> determine if that should be considered an issue in Axiom, axis2-saaj
> or axis2-jaxws. Please open a JIRA report and submit a test case that
> allows to reproduce the issue so that we can determine where this
> needs to be fixed.
>
> Andreas
>
> On Mon, Apr 11, 2011 at 10:41, Ivan <xh...@gmail.com> wrote:
> > Seems that axiom optimize the serialization, if no sub header element
> > exists, it will not output header element.
> > --->
> > if ((header != null) && (header.getFirstOMChild() != null)) {
> >                     serializeInternally((OMNodeImpl) header, writer);
> >                 }
> > <---
> >
> > 2011/4/11 Ivan <xh...@gmail.com>
> >>
> >> Hi, I am running Axis2 on Geronimo 3.0, and in the latest JAX-WS TCK
> >> testing, I got a NPE for some cases. The cause for it is that some cases
> >> will check whether those elements are not in the SOAP headers, while
> those
> >> soap message has no header element.
> >> From the Java doc of SOAPMessage, it writes :
> >>
> >> getSOAPHeader
> >>
> >> public SOAPHeader getSOAPHeader()
> >>                          throws SOAPException
> >>
> >> Gets the SOAP Header contained in this SOAPMessage object.
> >>
> >> Returns: the SOAPHeader object contained by this SOAPMessage object
> >> Throws: SOAPException - if the SOAP Header does not exist or cannot be
> >> retrieved Since: SAAJ 1.2
> >> From the Java Doc of SOAPEnvelop, it wirtes:
> >>
> >> getHeader
> >>
> >> SOAPHeader getHeader()
> >>                      throws SOAPException
> >>
> >> Returns the SOAPHeader object for this SOAPEnvelope object.
> >>
> >> A new SOAPMessage object is by default created with a SOAPEnvelope
> object
> >> that contains an empty SOAPHeader object. As a result, the method
> getHeader
> >> will always return a SOAPHeader object unless the header has been
> removed
> >> and a new one has not been added.
> >>
> >> Returns: the SOAPHeader object or null if there is none Throws:
> >> SOAPException - if there is a problem obtaining the SOAPHeader object
> >> It seems that there is different behavior for
> SOAPMessage.getSOAPHeader()
> >> and SOAPEnvelop.getHeader(). and in current axis2-saaj implementation,
> it
> >> always returns null while no header element exists.
> >> Personally, I thought it is an issue of saaj spec, it is not
> user-friendly
> >> to throw an exception while no header exists. Actually, I also test this
> >> with the ri saaj implementation, and it seems to have the same behavior
> with
> >> axis2-saaj.
> >> Another possible solution is to add an empty header element for those
> soap
> >> message if no header element exists, I could see it could be done in the
> >> SAAJConverter.
> >>
> >> Thoughts ?
> >> thanks.
> >> --
> >> Ivan
> >
> >
> >
> > --
> > Ivan
> >
>



-- 
Ivan

Re: SOAPMessage.getSOAPHeaders() return null while no headers in the soap envelope

Posted by Ivan <xh...@gmail.com>.
Open a JIRA https://issues.apache.org/jira/browse/AXIS2-5001 for this

2011/4/12 Andreas Veithen <an...@gmail.com>

> Ivan,
>
> Based on your description of the problem it is not possible to
> determine if that should be considered an issue in Axiom, axis2-saaj
> or axis2-jaxws. Please open a JIRA report and submit a test case that
> allows to reproduce the issue so that we can determine where this
> needs to be fixed.
>
> Andreas
>
> On Mon, Apr 11, 2011 at 10:41, Ivan <xh...@gmail.com> wrote:
> > Seems that axiom optimize the serialization, if no sub header element
> > exists, it will not output header element.
> > --->
> > if ((header != null) && (header.getFirstOMChild() != null)) {
> >                     serializeInternally((OMNodeImpl) header, writer);
> >                 }
> > <---
> >
> > 2011/4/11 Ivan <xh...@gmail.com>
> >>
> >> Hi, I am running Axis2 on Geronimo 3.0, and in the latest JAX-WS TCK
> >> testing, I got a NPE for some cases. The cause for it is that some cases
> >> will check whether those elements are not in the SOAP headers, while
> those
> >> soap message has no header element.
> >> From the Java doc of SOAPMessage, it writes :
> >>
> >> getSOAPHeader
> >>
> >> public SOAPHeader getSOAPHeader()
> >>                          throws SOAPException
> >>
> >> Gets the SOAP Header contained in this SOAPMessage object.
> >>
> >> Returns: the SOAPHeader object contained by this SOAPMessage object
> >> Throws: SOAPException - if the SOAP Header does not exist or cannot be
> >> retrieved Since: SAAJ 1.2
> >> From the Java Doc of SOAPEnvelop, it wirtes:
> >>
> >> getHeader
> >>
> >> SOAPHeader getHeader()
> >>                      throws SOAPException
> >>
> >> Returns the SOAPHeader object for this SOAPEnvelope object.
> >>
> >> A new SOAPMessage object is by default created with a SOAPEnvelope
> object
> >> that contains an empty SOAPHeader object. As a result, the method
> getHeader
> >> will always return a SOAPHeader object unless the header has been
> removed
> >> and a new one has not been added.
> >>
> >> Returns: the SOAPHeader object or null if there is none Throws:
> >> SOAPException - if there is a problem obtaining the SOAPHeader object
> >> It seems that there is different behavior for
> SOAPMessage.getSOAPHeader()
> >> and SOAPEnvelop.getHeader(). and in current axis2-saaj implementation,
> it
> >> always returns null while no header element exists.
> >> Personally, I thought it is an issue of saaj spec, it is not
> user-friendly
> >> to throw an exception while no header exists. Actually, I also test this
> >> with the ri saaj implementation, and it seems to have the same behavior
> with
> >> axis2-saaj.
> >> Another possible solution is to add an empty header element for those
> soap
> >> message if no header element exists, I could see it could be done in the
> >> SAAJConverter.
> >>
> >> Thoughts ?
> >> thanks.
> >> --
> >> Ivan
> >
> >
> >
> > --
> > Ivan
> >
>



-- 
Ivan

Re: SOAPMessage.getSOAPHeaders() return null while no headers in the soap envelope

Posted by Andreas Veithen <an...@gmail.com>.
Ivan,

Based on your description of the problem it is not possible to
determine if that should be considered an issue in Axiom, axis2-saaj
or axis2-jaxws. Please open a JIRA report and submit a test case that
allows to reproduce the issue so that we can determine where this
needs to be fixed.

Andreas

On Mon, Apr 11, 2011 at 10:41, Ivan <xh...@gmail.com> wrote:
> Seems that axiom optimize the serialization, if no sub header element
> exists, it will not output header element.
> --->
> if ((header != null) && (header.getFirstOMChild() != null)) {
>                     serializeInternally((OMNodeImpl) header, writer);
>                 }
> <---
>
> 2011/4/11 Ivan <xh...@gmail.com>
>>
>> Hi, I am running Axis2 on Geronimo 3.0, and in the latest JAX-WS TCK
>> testing, I got a NPE for some cases. The cause for it is that some cases
>> will check whether those elements are not in the SOAP headers, while those
>> soap message has no header element.
>> From the Java doc of SOAPMessage, it writes :
>>
>> getSOAPHeader
>>
>> public SOAPHeader getSOAPHeader()
>>                          throws SOAPException
>>
>> Gets the SOAP Header contained in this SOAPMessage object.
>>
>> Returns: the SOAPHeader object contained by this SOAPMessage object
>> Throws: SOAPException - if the SOAP Header does not exist or cannot be
>> retrieved Since: SAAJ 1.2
>> From the Java Doc of SOAPEnvelop, it wirtes:
>>
>> getHeader
>>
>> SOAPHeader getHeader()
>>                      throws SOAPException
>>
>> Returns the SOAPHeader object for this SOAPEnvelope object.
>>
>> A new SOAPMessage object is by default created with a SOAPEnvelope object
>> that contains an empty SOAPHeader object. As a result, the method getHeader
>> will always return a SOAPHeader object unless the header has been removed
>> and a new one has not been added.
>>
>> Returns: the SOAPHeader object or null if there is none Throws:
>> SOAPException - if there is a problem obtaining the SOAPHeader object
>> It seems that there is different behavior for SOAPMessage.getSOAPHeader()
>> and SOAPEnvelop.getHeader(). and in current axis2-saaj implementation, it
>> always returns null while no header element exists.
>> Personally, I thought it is an issue of saaj spec, it is not user-friendly
>> to throw an exception while no header exists. Actually, I also test this
>> with the ri saaj implementation, and it seems to have the same behavior with
>> axis2-saaj.
>> Another possible solution is to add an empty header element for those soap
>> message if no header element exists, I could see it could be done in the
>> SAAJConverter.
>>
>> Thoughts ?
>> thanks.
>> --
>> Ivan
>
>
>
> --
> Ivan
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: SOAPMessage.getSOAPHeaders() return null while no headers in the soap envelope

Posted by Andreas Veithen <an...@gmail.com>.
Ivan,

Based on your description of the problem it is not possible to
determine if that should be considered an issue in Axiom, axis2-saaj
or axis2-jaxws. Please open a JIRA report and submit a test case that
allows to reproduce the issue so that we can determine where this
needs to be fixed.

Andreas

On Mon, Apr 11, 2011 at 10:41, Ivan <xh...@gmail.com> wrote:
> Seems that axiom optimize the serialization, if no sub header element
> exists, it will not output header element.
> --->
> if ((header != null) && (header.getFirstOMChild() != null)) {
>                     serializeInternally((OMNodeImpl) header, writer);
>                 }
> <---
>
> 2011/4/11 Ivan <xh...@gmail.com>
>>
>> Hi, I am running Axis2 on Geronimo 3.0, and in the latest JAX-WS TCK
>> testing, I got a NPE for some cases. The cause for it is that some cases
>> will check whether those elements are not in the SOAP headers, while those
>> soap message has no header element.
>> From the Java doc of SOAPMessage, it writes :
>>
>> getSOAPHeader
>>
>> public SOAPHeader getSOAPHeader()
>>                          throws SOAPException
>>
>> Gets the SOAP Header contained in this SOAPMessage object.
>>
>> Returns: the SOAPHeader object contained by this SOAPMessage object
>> Throws: SOAPException - if the SOAP Header does not exist or cannot be
>> retrieved Since: SAAJ 1.2
>> From the Java Doc of SOAPEnvelop, it wirtes:
>>
>> getHeader
>>
>> SOAPHeader getHeader()
>>                      throws SOAPException
>>
>> Returns the SOAPHeader object for this SOAPEnvelope object.
>>
>> A new SOAPMessage object is by default created with a SOAPEnvelope object
>> that contains an empty SOAPHeader object. As a result, the method getHeader
>> will always return a SOAPHeader object unless the header has been removed
>> and a new one has not been added.
>>
>> Returns: the SOAPHeader object or null if there is none Throws:
>> SOAPException - if there is a problem obtaining the SOAPHeader object
>> It seems that there is different behavior for SOAPMessage.getSOAPHeader()
>> and SOAPEnvelop.getHeader(). and in current axis2-saaj implementation, it
>> always returns null while no header element exists.
>> Personally, I thought it is an issue of saaj spec, it is not user-friendly
>> to throw an exception while no header exists. Actually, I also test this
>> with the ri saaj implementation, and it seems to have the same behavior with
>> axis2-saaj.
>> Another possible solution is to add an empty header element for those soap
>> message if no header element exists, I could see it could be done in the
>> SAAJConverter.
>>
>> Thoughts ?
>> thanks.
>> --
>> Ivan
>
>
>
> --
> Ivan
>

Re: SOAPMessage.getSOAPHeaders() return null while no headers in the soap envelope

Posted by Ivan <xh...@gmail.com>.
Seems that axiom optimize the serialization, if no sub header element
exists, it will not output header element.
--->
if ((header != null) && (header.getFirstOMChild() != null)) {
                    serializeInternally((OMNodeImpl) header, writer);
                }
<---

2011/4/11 Ivan <xh...@gmail.com>

> Hi, I am running Axis2 on Geronimo 3.0, and in the latest JAX-WS TCK
> testing, I got a NPE for some cases. The cause for it is that some cases
> will check whether those elements are not in the SOAP headers, while those
> soap message has no header element.
> From the Java doc of SOAPMessage, it writes :
> getSOAPHeader
>
> public SOAPHeader <http://j2ee6/api/javax/xml/soap/SOAPHeader.html> *getSOAPHeader*()
>                          throws SOAPException <http://j2ee6/api/javax/xml/soap/SOAPException.html>
>
> Gets the SOAP Header contained in this SOAPMessage object.
>
>  *Returns:* the SOAPHeader object contained by this SOAPMessage object *
> Throws:* SOAPException - if the SOAP Header does not exist or cannot be
> retrieved *Since:* SAAJ 1.2
> From the Java Doc of SOAPEnvelop, it wirtes:
> getHeader
>
> SOAPHeader <http://j2ee6/api/javax/xml/soap/SOAPHeader.html> *getHeader*()
>                      throws SOAPException <http://j2ee6/api/javax/xml/soap/SOAPException.html>
>
> Returns the SOAPHeader object for this SOAPEnvelope object.
>
> A new SOAPMessage object is by default created with a SOAPEnvelope object
> that contains an empty SOAPHeader object. As a result, the method
> getHeader will always return a SOAPHeader object unless the header has
> been removed and a new one has not been added.
>  *Returns:* the SOAPHeader object or null if there is none *Throws:*
> SOAPException - if there is a problem obtaining the SOAPHeader object
> It seems that there is different behavior for SOAPMessage.getSOAPHeader()
> and SOAPEnvelop.getHeader(). and in current axis2-saaj implementation, it
> always returns null while no header element exists.
> Personally, I thought it is an issue of saaj spec, it is not user-friendly
> to throw an exception while no header exists. Actually, I also test this
> with the ri saaj implementation, and it seems to have the same behavior with
> axis2-saaj.
> Another possible solution is to add an empty header element for those soap
> message if no header element exists, I could see it could be done in the
> SAAJConverter.
>
> Thoughts ?
> thanks.
> --
> Ivan
>



-- 
Ivan

Re: SOAPMessage.getSOAPHeaders() return null while no headers in the soap envelope

Posted by Ivan <xh...@gmail.com>.
Seems that axiom optimize the serialization, if no sub header element
exists, it will not output header element.
--->
if ((header != null) && (header.getFirstOMChild() != null)) {
                    serializeInternally((OMNodeImpl) header, writer);
                }
<---

2011/4/11 Ivan <xh...@gmail.com>

> Hi, I am running Axis2 on Geronimo 3.0, and in the latest JAX-WS TCK
> testing, I got a NPE for some cases. The cause for it is that some cases
> will check whether those elements are not in the SOAP headers, while those
> soap message has no header element.
> From the Java doc of SOAPMessage, it writes :
> getSOAPHeader
>
> public SOAPHeader <http://j2ee6/api/javax/xml/soap/SOAPHeader.html> *getSOAPHeader*()
>                          throws SOAPException <http://j2ee6/api/javax/xml/soap/SOAPException.html>
>
> Gets the SOAP Header contained in this SOAPMessage object.
>
>  *Returns:* the SOAPHeader object contained by this SOAPMessage object *
> Throws:* SOAPException - if the SOAP Header does not exist or cannot be
> retrieved *Since:* SAAJ 1.2
> From the Java Doc of SOAPEnvelop, it wirtes:
> getHeader
>
> SOAPHeader <http://j2ee6/api/javax/xml/soap/SOAPHeader.html> *getHeader*()
>                      throws SOAPException <http://j2ee6/api/javax/xml/soap/SOAPException.html>
>
> Returns the SOAPHeader object for this SOAPEnvelope object.
>
> A new SOAPMessage object is by default created with a SOAPEnvelope object
> that contains an empty SOAPHeader object. As a result, the method
> getHeader will always return a SOAPHeader object unless the header has
> been removed and a new one has not been added.
>  *Returns:* the SOAPHeader object or null if there is none *Throws:*
> SOAPException - if there is a problem obtaining the SOAPHeader object
> It seems that there is different behavior for SOAPMessage.getSOAPHeader()
> and SOAPEnvelop.getHeader(). and in current axis2-saaj implementation, it
> always returns null while no header element exists.
> Personally, I thought it is an issue of saaj spec, it is not user-friendly
> to throw an exception while no header exists. Actually, I also test this
> with the ri saaj implementation, and it seems to have the same behavior with
> axis2-saaj.
> Another possible solution is to add an empty header element for those soap
> message if no header element exists, I could see it could be done in the
> SAAJConverter.
>
> Thoughts ?
> thanks.
> --
> Ivan
>



-- 
Ivan