Re: [Axis2] AXIOM Custom Serializer/Deserializer

2007-05-08 Thread Glen Mazza
Am Dienstag, den 08.05.2007, 14:46 +0800 schrieb Xinjun Chen:
>  
> 4) Comment the line SOAPEnvelope.toStringWithConsume(). Test the
> application again. The application works properly. 
>  
> 5) Change the line to SOAPEnvelope.toString(). Test the application.
> It works properly. 
>  
> Previously I think the toStringWithConsume and toString will differ in
> terms of performance since one is cached but the other is not. This
> difference should not cause a program to run incorrectly. 
>  

Or more precisely (according to the fourth paragraph of this article[1])
toStringWithConsume() caches only if you set the caching flag to "true".

I'm not knowledgable enough about the source code to know if this is an
Axis error (but it is good that this thread is part of the searchable
archives)--but it appears that toString() is the only function your
logger should be calling, as toStringWithConsume() would cause you to
lose part of your input stream.

Glen

[1] http://wso2.org/library/351




> Regards, 
> Xinjun
>  
> 
>  
> On 5/4/07, Xinjun Chen <[EMAIL PROTECTED]> wrote: 
> Hi Glen, 
>  
> Thanks for the pointer. 
>  
> I agree with your point 1), 2), and 3). 
> Regarding your guess, I need to do in-server debugging to
> confirm. 
>  
> If "needToThrowEndDocument" is different for two different
> scenarios, it is possible that hasNext() return different
> boolean values. But the problem I face below is that hasNext()
> in two scenarios return the same boolean value (TRUE),
> but next() in different scenario executes different logic.  
>  
> Anyway, I will download the source of AXIOM 1.2.2 to do the in
> server debugging and revert to this forum.
>  
>  
> Regards,
> Xinjun 
> 
>  
> On 5/4/07, Glen Mazza <[EMAIL PROTECTED] > wrote: 
> Here is the source code of OMStAXWrapper:
> http://tinyurl.com/33k5m7 
> 
> Here are some things I noticed:
> 1.)  The NPE occurs at generateEvents on line 1115
> because the passed-in
> "node" parameter is null.
> 
> 2.)  Method next(), which calls generateEvents() at
> line 911, does not 
> check to see if the currentNode parameter is null.  So
> apparently we
> have a case where the state is NAVIGABLE but
> currentNode is null.  (This
> I believe is OK, because client code should call
> hasNext() before
> calling next().)
> 
> 3.)  Your code calls method hasNext() at line 797
> before calling next().
> But you can see the AXIOM implementation of hasNext()
> has a different
> business logic depending on the boolean value of 
> "needToThrowEndDocument".
> 
> So my guess would be that the needToThrowEndDocument
> value is different
> between standalone usage and web service usage, which
> changes the
> business logic of hasNext().  Further, the business
> logic for standalone 
> is correct but not working properly under certain
> circumstances for web
> service usage (i.e., it returns true when it should be
> false, causing
> your code to call next() erroneously, causing the
> NPE.)
> 
> Glen
> 
> 
> Am Freitag, den 04.05.2007, 11:36 +0800 schrieb Xinjun
> Chen:
> > I have tried to invoke the EPaymentHandler from JSP
> directly, it works
> > fine. The EPaymentHandler.execute() invokes
> > CreditCardPaymentRequestBinder.toObject .
> >
> > But when I invoke the EPaymentHandler from inside a
> child class of
> >
> org.apache.axis2.receivers.RawXMLINOutMessageReceiver,
> then I get the
> > NPE.
> > The child class of RawXMLINOutMessageReceiver
> override the 
> > invokeBusinessLogic method as follows:
> >
> >  public void invokeBusinessLogic(MessageContext
> msgContext,
> > MessageContext newmsgContext) throws AxisFault {
> >
> >log.debug("EPaymentHandler invoked."); 
> >try {
> >epayHandler.execute (msgContext,
> newmsgContext);
> >   

Re: [Axis2] AXIOM Custom Serializer/Deserializer

2007-05-07 Thread Xinjun Chen

Hi Dim and Glen,

Thanks for your previous reply.

I have solved by my problem with the following experience:

1) Upgrade Axis2 to the latest version 1.2. And check the application.
   The result is that the problem persists: Using standalone program
the binders work fine. Using the web service, the OMStAXWrapper throw NPE in
generateEvent() method.

2) Downloaded Axiom 1.2.4 source and Axis2 1.2 source for debugging.

3) Through the in-server debugging, I found that before invoking my custom
MessageReceiver, the custom Dispatcher has one line logging the request
SOAPEnvelope using SOAPEnvelope.toStringWithConsume().

This toStringWithConsume() will indirectly invoke
StreamingOMSerializer.serialize() with the cache=false. During the
invocation of toStringWithConsume(), the "needToThrowEndDocument" is true.
The SOAPEnvelope is logged properly.

When executing my custom binder class, the "needToThrowEndDocument" changes
to false. I still don't know why it changes to false.

4) Comment the line SOAPEnvelope.toStringWithConsume(). Test the application
again. The application works properly.

5) Change the line to SOAPEnvelope.toString(). Test the application. It
works properly.

Previously I think the toStringWithConsume and toString will differ in terms
of performance since one is cached but the other is not. This difference
should not cause a program to run incorrectly.

Regards,
Xinjun



On 5/4/07, Xinjun Chen <[EMAIL PROTECTED]> wrote:


Hi Glen,

Thanks for the pointer.

I agree with your point 1), 2), and 3).
Regarding your guess, I need to do in-server debugging to confirm.

If "needToThrowEndDocument" is different for two different scenarios, it
is possible that hasNext() return different boolean values. But the problem
I face below is that hasNext() in two scenarios return the same boolean
value (TRUE), but next() in different scenario executes different logic.

Anyway, I will download the source of AXIOM 1.2.2 to do the in server
debugging and revert to this forum.


Regards,
Xinjun


 On 5/4/07, Glen Mazza <[EMAIL PROTECTED]> wrote:
>
> Here is the source code of OMStAXWrapper:
> http://tinyurl.com/33k5m7
>
> Here are some things I noticed:
> 1.)  The NPE occurs at generateEvents on line 1115 because the passed-in
> "node" parameter is null.
>
> 2.)  Method next(), which calls generateEvents() at line 911, does not
> check to see if the currentNode parameter is null.  So apparently we
> have a case where the state is NAVIGABLE but currentNode is null.  (This
> I believe is OK, because client code should call hasNext() before
> calling next().)
>
> 3.)  Your code calls method hasNext() at line 797 before calling next().
> But you can see the AXIOM implementation of hasNext() has a different
> business logic depending on the boolean value of
> "needToThrowEndDocument".
>
> So my guess would be that the needToThrowEndDocument value is different
> between standalone usage and web service usage, which changes the
> business logic of hasNext().  Further, the business logic for standalone
>
> is correct but not working properly under certain circumstances for web
> service usage (i.e., it returns true when it should be false, causing
> your code to call next() erroneously, causing the NPE.)
>
> Glen
>
>
> Am Freitag, den 04.05.2007, 11:36 +0800 schrieb Xinjun Chen:
> > I have tried to invoke the EPaymentHandler from JSP directly, it works
> > fine. The EPaymentHandler.execute() invokes
> > CreditCardPaymentRequestBinder.toObject .
> >
> > But when I invoke the EPaymentHandler from inside a child class of
> > org.apache.axis2.receivers.RawXMLINOutMessageReceiver, then I get the
> > NPE.
> > The child class of RawXMLINOutMessageReceiver override the
> > invokeBusinessLogic method as follows:
> >
> >  public void invokeBusinessLogic(MessageContext msgContext,
> > MessageContext newmsgContext) throws AxisFault {
> >
> >log.debug("EPaymentHandler invoked.");
> >try {
> >epayHandler.execute (msgContext, newmsgContext);
> >// epayHandler will invoke CreditCardPaymentRequestBinder.
> >} catch (Exception e) {
> >log.error(e);
> >throw new AxisFault(e);
> >}
> >  }
> >
> > As can be seen, this method does not contain any code dealing with
> > StAX parser.
> > I am wondering which step affects the StAX parser and cause the
> > org.apache.axiom.om.impl.llom.OMStAXWrapper.generateEvents(
> OMStAXWrapper.java:1115) NPE.
> > I am not familiar with the implementation of AXIOM, and now cannot
> > proceed.
> >
> > As far as I know, wstx-asl-3.2.0.jar is the implementation of
> > stax-api. How about the axiom-impl-1.2.2.jar? Does it use
> > wstx-asl-3.2.0?
> >
> > Regards,
> > Xinjun
> >
> >
> > On 5/4/07, Xinjun Chen < [EMAIL PROTECTED]> wrote:
> > Hi Dims,
> >
> > The same soap request works with my standalone program. The
> > same method toObject runs correctly gives correct result.
> >
> > Regards,
> > Xinjun
> >
> > On 5

Re: [Axis2] AXIOM Custom Serializer/Deserializer

2007-05-03 Thread Xinjun Chen

Hi Glen,

Thanks for the pointer.

I agree with your point 1), 2), and 3).
Regarding your guess, I need to do in-server debugging to confirm.

If "needToThrowEndDocument" is different for two different scenarios, it is
possible that hasNext() return different boolean values. But the problem I
face below is that hasNext() in two scenarios return the same boolean value
(TRUE), but next() in different scenario executes different logic.

Anyway, I will download the source of AXIOM 1.2.2 to do the in server
debugging and revert to this forum.


Regards,
Xinjun


On 5/4/07, Glen Mazza <[EMAIL PROTECTED]> wrote:


Here is the source code of OMStAXWrapper:
http://tinyurl.com/33k5m7

Here are some things I noticed:
1.)  The NPE occurs at generateEvents on line 1115 because the passed-in
"node" parameter is null.

2.)  Method next(), which calls generateEvents() at line 911, does not
check to see if the currentNode parameter is null.  So apparently we
have a case where the state is NAVIGABLE but currentNode is null.  (This
I believe is OK, because client code should call hasNext() before
calling next().)

3.)  Your code calls method hasNext() at line 797 before calling next().
But you can see the AXIOM implementation of hasNext() has a different
business logic depending on the boolean value of
"needToThrowEndDocument".

So my guess would be that the needToThrowEndDocument value is different
between standalone usage and web service usage, which changes the
business logic of hasNext().  Further, the business logic for standalone
is correct but not working properly under certain circumstances for web
service usage (i.e., it returns true when it should be false, causing
your code to call next() erroneously, causing the NPE.)

Glen


Am Freitag, den 04.05.2007, 11:36 +0800 schrieb Xinjun Chen:
> I have tried to invoke the EPaymentHandler from JSP directly, it works
> fine. The EPaymentHandler.execute() invokes
> CreditCardPaymentRequestBinder.toObject.
>
> But when I invoke the EPaymentHandler from inside a child class of
> org.apache.axis2.receivers.RawXMLINOutMessageReceiver, then I get the
> NPE.
> The child class of RawXMLINOutMessageReceiver override the
> invokeBusinessLogic method as follows:
>
>  public void invokeBusinessLogic(MessageContext msgContext,
> MessageContext newmsgContext) throws AxisFault {
>
>log.debug("EPaymentHandler invoked.");
>try {
>epayHandler.execute (msgContext, newmsgContext);
>// epayHandler will invoke CreditCardPaymentRequestBinder.
>} catch (Exception e) {
>log.error(e);
>throw new AxisFault(e);
>}
>  }
>
> As can be seen, this method does not contain any code dealing with
> StAX parser.
> I am wondering which step affects the StAX parser and cause the
> org.apache.axiom.om.impl.llom.OMStAXWrapper.generateEvents(
OMStAXWrapper.java:1115) NPE.
> I am not familiar with the implementation of AXIOM, and now cannot
> proceed.
>
> As far as I know, wstx-asl-3.2.0.jar is the implementation of
> stax-api. How about the axiom-impl-1.2.2.jar? Does it use
> wstx-asl-3.2.0?
>
> Regards,
> Xinjun
>
>
> On 5/4/07, Xinjun Chen <[EMAIL PROTECTED]> wrote:
> Hi Dims,
>
> The same soap request works with my standalone program. The
> same method toObject runs correctly gives correct result.
>
> Regards,
> Xinjun
>
> On 5/3/07, Davanum Srinivas <[EMAIL PROTECTED] > wrote:
> Xinjun,
>
> can you run tcpmon to capture the soap request and use
> that xml with
> your stand alone program to see if that works?
>
> -- dims
>
> On 5/3/07, Xinjun Chen <[EMAIL PROTECTED]> wrote:
> >
> >
> > Hi,
> >
> > I wrote a sample custom serializer/deserializer to
> serialize an object. When
> > I use a standalone program to test the serializer,
> it works fine. But when I
> > deploy the serializer as part of a web service and
> and invoke the web
> > service through a SOAP request, I got the following
> null pointer execption.
> > I googled but didn't find the reason of this. Why
> does the NPE occur only
> > when I deploy the binder as part of the web service?
> I used the same
> > SOAPEnvelope to test.
> >
> >
> >
> > java.lang.NullPointerException
> > at
> >
>
org.apache.axiom.om.impl.llom.OMStAXWrapper.generateEvents(OMStAXWrap
> > per.java:1115)
> > at
> > org.apache.axiom.om.impl.llom.OMStAXWrapper.next
> (OMStAXWrapper.java:9
> >  11)
> > at
> 

Re: [Axis2] AXIOM Custom Serializer/Deserializer

2007-05-03 Thread Glen Mazza
Here is the source code of OMStAXWrapper:
http://tinyurl.com/33k5m7

Here are some things I noticed:
1.)  The NPE occurs at generateEvents on line 1115 because the passed-in
"node" parameter is null.

2.)  Method next(), which calls generateEvents() at line 911, does not
check to see if the currentNode parameter is null.  So apparently we
have a case where the state is NAVIGABLE but currentNode is null.  (This
I believe is OK, because client code should call hasNext() before
calling next().)

3.)  Your code calls method hasNext() at line 797 before calling next().
But you can see the AXIOM implementation of hasNext() has a different
business logic depending on the boolean value of
"needToThrowEndDocument".

So my guess would be that the needToThrowEndDocument value is different
between standalone usage and web service usage, which changes the
business logic of hasNext().  Further, the business logic for standalone
is correct but not working properly under certain circumstances for web
service usage (i.e., it returns true when it should be false, causing
your code to call next() erroneously, causing the NPE.)

Glen


Am Freitag, den 04.05.2007, 11:36 +0800 schrieb Xinjun Chen:
> I have tried to invoke the EPaymentHandler from JSP directly, it works
> fine. The EPaymentHandler.execute() invokes
> CreditCardPaymentRequestBinder.toObject.
>  
> But when I invoke the EPaymentHandler from inside a child class of
> org.apache.axis2.receivers.RawXMLINOutMessageReceiver, then I get the
> NPE. 
> The child class of RawXMLINOutMessageReceiver override the
> invokeBusinessLogic method as follows:
> 
>  public void invokeBusinessLogic(MessageContext msgContext,
> MessageContext newmsgContext) throws AxisFault {
>   
>log.debug("EPaymentHandler invoked.");
>try {
>epayHandler.execute (msgContext, newmsgContext);
>// epayHandler will invoke CreditCardPaymentRequestBinder.
>} catch (Exception e) {
>log.error(e);
>throw new AxisFault(e);
>}
>  }
>  
> As can be seen, this method does not contain any code dealing with
> StAX parser. 
> I am wondering which step affects the StAX parser and cause the
> org.apache.axiom.om.impl.llom.OMStAXWrapper.generateEvents(OMStAXWrapper.java:1115)
>  NPE. 
> I am not familiar with the implementation of AXIOM, and now cannot
> proceed. 
>  
> As far as I know, wstx-asl-3.2.0.jar is the implementation of
> stax-api. How about the axiom-impl-1.2.2.jar? Does it use
> wstx-asl-3.2.0?  
>  
> Regards, 
> Xinjun
> 
>  
> On 5/4/07, Xinjun Chen <[EMAIL PROTECTED]> wrote: 
> Hi Dims, 
>  
> The same soap request works with my standalone program. The
> same method toObject runs correctly gives correct result. 
>  
> Regards, 
> Xinjun
>  
> On 5/3/07, Davanum Srinivas <[EMAIL PROTECTED] > wrote: 
> Xinjun,
> 
> can you run tcpmon to capture the soap request and use
> that xml with
> your stand alone program to see if that works? 
> 
> -- dims
> 
> On 5/3/07, Xinjun Chen <[EMAIL PROTECTED]> wrote:
> >
> >
> > Hi,
> >
> > I wrote a sample custom serializer/deserializer to
> serialize an object. When 
> > I use a standalone program to test the serializer,
> it works fine. But when I
> > deploy the serializer as part of a web service and
> and invoke the web 
> > service through a SOAP request, I got the following
> null pointer execption. 
> > I googled but didn't find the reason of this. Why
> does the NPE occur only
> > when I deploy the binder as part of the web service?
> I used the same 
> > SOAPEnvelope to test.
> >
> >
> >
> > java.lang.NullPointerException
> > at
> >
> 
> org.apache.axiom.om.impl.llom.OMStAXWrapper.generateEvents(OMStAXWrap
> > per.java:1115)
> > at 
> > org.apache.axiom.om.impl.llom.OMStAXWrapper.next
> (OMStAXWrapper.java:9
> >  11)
> > at
> >
> 
> com.mycom.CreditCardPaymentRequestBinder.toObject(CreditCardPaymentRequestBinder.java:138)
> >
> >
> >
> > The toObject method definition is as follows: 
> >
> >  public CreditCardPaymentRequest toObject(QName
> qname, XMLStreamReader
> > reader) throws XMLStreamException {
> >   CreditCardPaymentRequ

Re: [Axis2] AXIOM Custom Serializer/Deserializer

2007-05-03 Thread Xinjun Chen

I have tried to invoke the EPaymentHandler from JSP directly, it works fine.
The EPaymentHandler.execute() invokes
CreditCardPaymentRequestBinder.toObject.

But when I invoke the EPaymentHandler from inside a child class of
org.apache.axis2.receivers.RawXMLINOutMessageReceiver, then I get the NPE.
The child class of RawXMLINOutMessageReceiver override the
invokeBusinessLogic method as follows:

public void invokeBusinessLogic(MessageContext msgContext, MessageContext
newmsgContext) throws AxisFault {

  log.debug("EPaymentHandler invoked.");
  try {
  epayHandler.execute(msgContext, newmsgContext);
  // epayHandler will invoke CreditCardPaymentRequestBinder.
  } catch (Exception e) {
  log.error(e);
  throw new AxisFault(e);
  }
}

As can be seen, this method does not contain any code dealing with StAX
parser.
I am wondering which step affects the StAX parser and cause the
org.apache.axiom.om.impl.llom.OMStAXWrapper.generateEvents(
OMStAXWrapper.java:1115) NPE.
I am not familiar with the implementation of AXIOM, and now cannot proceed.

As far as I know, wstx-asl-3.2.0.jar is the implementation of stax-api. How
about the axiom-impl-1.2.2.jar? Does it use wstx-asl-3.2.0?

Regards,
Xinjun


On 5/4/07, Xinjun Chen <[EMAIL PROTECTED]> wrote:


Hi Dims,

The same soap request works with my standalone program. The same method
toObject runs correctly gives correct result.

Regards,
Xinjun

 On 5/3/07, Davanum Srinivas <[EMAIL PROTECTED]> wrote:
>
> Xinjun,
>
> can you run tcpmon to capture the soap request and use that xml with
> your stand alone program to see if that works?
>
> -- dims
>
> On 5/3/07, Xinjun Chen <[EMAIL PROTECTED]> wrote:
> >
> >
> > Hi,
> >
> > I wrote a sample custom serializer/deserializer to serialize an
> object. When
> > I use a standalone program to test the serializer, it works fine. But
> when I
> > deploy the serializer as part of a web service and and invoke the web
> > service through a SOAP request, I got the following null pointer
> execption.
> > I googled but didn't find the reason of this. Why does the NPE occur
> only
> > when I deploy the binder as part of the web service? I used the same
> > SOAPEnvelope to test.
> >
> >
> >
> > java.lang.NullPointerException
> > at
> > org.apache.axiom.om.impl.llom.OMStAXWrapper.generateEvents(OMStAXWrap
> > per.java:1115)
> > at
> > org.apache.axiom.om.impl.llom.OMStAXWrapper.next (OMStAXWrapper.java:9
> >  11)
> > at
> > com.mycom.CreditCardPaymentRequestBinder.toObject(
> CreditCardPaymentRequestBinder.java:138)
> >
> >
> >
> > The toObject method definition is as follows:
> >
> >  public CreditCardPaymentRequest toObject(QName qname, XMLStreamReader
> > reader) throws XMLStreamException {
> >   CreditCardPaymentRequest obj = new CreditCardPaymentRequest();
> >
> >   String rootElementName = qname.getLocalPart ();
> >   String uri = qname.getNamespaceURI();
> >
> >   if(!rootNsUri.equals(uri)) {
> >throw new XMLStreamException("Invalid namespace " + uri + ".
> Expected
> > namespace uri is " + rootNsUri);
> >   }
> >
> >   while(reader.hasNext()) {
> >int type = reader.next(); // Line number: 138
> >
> >if(XMLStreamConstants.START_ELEMENT == type){
> > String element = reader.getLocalName ();
> >
> > if( rootLocalName.equals(element) ) {
> >  continue;
> > } else if( element.equals("cardNumber") ){
> >  obj.setCardNumber(reader.getElementText());
> > } else if( element.equals("expiryMonth") ) {
> >  obj.setExpiryMonth(reader.getElementText());
> > } else if( element.equals("expiryYear") ) {
> >  obj.setExpiryYear(reader.getElementText());
> > } else if( element.equals("brand") ) {
> >  obj.setBrand(reader.getElementText());
> > } else if( element.equals("totalAmount") ) {
> >  obj.setTotalAmount(reader.getElementText ());
> > } else if( element.equals("currency") ) {
> >  obj.setCurrency(reader.getElementText());
> > } else if( element.equals("systemId") ) {
> >  obj.setSystemId(reader.getElementText ());
> > } else if( element.equals("referenceNumber") ) {
> >  obj.setReferenceNumber(reader.getElementText());
> > } else if( element.equals("op") ) {
> >  obj.setOp(reader.getElementText ());
> > } else {
> >  throw new RuntimeException("Unexpected element " + element);
> > }
> >}
> >
> >if(XMLStreamConstants.END_ELEMENT == type){
> > if(reader.getLocalName ().equals(rootElementName)){
> >  break;
> > }
> >}
> >
> >   }
> >
> >   return obj;
> >  }
> >
> >
> >
> >
> >
> > Regards,
> >
> > Xinjun
>
>
> --
> Davanum Srinivas :: http://davanum.wordpress.com
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



Re: [Axis2] AXIOM Custom Serializer/Deserializer

2007-05-03 Thread Xinjun Chen

I have tried to invoke the EPaymentHandler from JSP directly, it works fine.
The EPaymentHandler.execute() invokes
CreditCardPaymentRequestBinder.toObject.

But when I invoke the EPaymentHandler from inside a child class of
org.apache.axis2.receivers.RawXMLINOutMessageReceiver, then I get the NPE.
The child class of RawXMLINOutMessageReceiver override the
invokeBusinessLogic method as follows:

public void invokeBusinessLogic(MessageContext msgContext, MessageContext
newmsgContext) throws AxisFault {

  log.debug("EPaymentHandler invoked.");
  try {
  epayHandler.execute(msgContext, newmsgContext);
  // epayHandler will invoke CreditCardPaymentRequestBinder.
  } catch (Exception e) {
  log.error(e);
  throw new AxisFault(e);
  }
}

As can be seen, this method does not contain any code dealing with StAX
parser.
I am wondering which step affects the StAX parser and cause the
org.apache.axiom.om.impl.llom.OMStAXWrapper.generateEvents(
OMStAXWrapper.java:1115) NPE.
I am not familiar with the implementation of AXIOM, and now cannot proceed.

As far as I know, wstx-asl-3.2.0.jar is the implementation of stax-api. How
about the axiom-impl-1.2.2.jar? Does it use wstx-asl-3.2.0?

Regards,
Xinjun


On 5/4/07, Xinjun Chen <[EMAIL PROTECTED]> wrote:


Hi Dims,

The same soap request works with my standalone program. The same method
toObject runs correctly gives correct result.

Regards,
Xinjun

 On 5/3/07, Davanum Srinivas <[EMAIL PROTECTED]> wrote:
>
> Xinjun,
>
> can you run tcpmon to capture the soap request and use that xml with
> your stand alone program to see if that works?
>
> -- dims
>
> On 5/3/07, Xinjun Chen <[EMAIL PROTECTED]> wrote:
> >
> >
> > Hi,
> >
> > I wrote a sample custom serializer/deserializer to serialize an
> object. When
> > I use a standalone program to test the serializer, it works fine. But
> when I
> > deploy the serializer as part of a web service and and invoke the web
> > service through a SOAP request, I got the following null pointer
> execption.
> > I googled but didn't find the reason of this. Why does the NPE occur
> only
> > when I deploy the binder as part of the web service? I used the same
> > SOAPEnvelope to test.
> >
> >
> >
> > java.lang.NullPointerException
> > at
> > org.apache.axiom.om.impl.llom.OMStAXWrapper.generateEvents(OMStAXWrap
> > per.java:1115)
> > at
> > org.apache.axiom.om.impl.llom.OMStAXWrapper.next (OMStAXWrapper.java:9
> >  11)
> > at
> > com.mycom.CreditCardPaymentRequestBinder.toObject(
> CreditCardPaymentRequestBinder.java:138)
> >
> >
> >
> > The toObject method definition is as follows:
> >
> >  public CreditCardPaymentRequest toObject(QName qname, XMLStreamReader
> > reader) throws XMLStreamException {
> >   CreditCardPaymentRequest obj = new CreditCardPaymentRequest();
> >
> >   String rootElementName = qname.getLocalPart ();
> >   String uri = qname.getNamespaceURI();
> >
> >   if(!rootNsUri.equals(uri)) {
> >throw new XMLStreamException("Invalid namespace " + uri + ".
> Expected
> > namespace uri is " + rootNsUri);
> >   }
> >
> >   while(reader.hasNext()) {
> >int type = reader.next(); // Line number: 138
> >
> >if(XMLStreamConstants.START_ELEMENT == type){
> > String element = reader.getLocalName ();
> >
> > if( rootLocalName.equals(element) ) {
> >  continue;
> > } else if( element.equals("cardNumber") ){
> >  obj.setCardNumber(reader.getElementText());
> > } else if( element.equals("expiryMonth") ) {
> >  obj.setExpiryMonth(reader.getElementText());
> > } else if( element.equals("expiryYear") ) {
> >  obj.setExpiryYear(reader.getElementText());
> > } else if( element.equals("brand") ) {
> >  obj.setBrand(reader.getElementText());
> > } else if( element.equals("totalAmount") ) {
> >  obj.setTotalAmount(reader.getElementText ());
> > } else if( element.equals("currency") ) {
> >  obj.setCurrency(reader.getElementText());
> > } else if( element.equals("systemId") ) {
> >  obj.setSystemId(reader.getElementText ());
> > } else if( element.equals("referenceNumber") ) {
> >  obj.setReferenceNumber(reader.getElementText());
> > } else if( element.equals("op") ) {
> >  obj.setOp(reader.getElementText ());
> > } else {
> >  throw new RuntimeException("Unexpected element " + element);
> > }
> >}
> >
> >if(XMLStreamConstants.END_ELEMENT == type){
> > if(reader.getLocalName ().equals(rootElementName)){
> >  break;
> > }
> >}
> >
> >   }
> >
> >   return obj;
> >  }
> >
> >
> >
> >
> >
> > Regards,
> >
> > Xinjun
>
>
> --
> Davanum Srinivas :: http://davanum.wordpress.com
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



Re: [Axis2] AXIOM Custom Serializer/Deserializer

2007-05-03 Thread Xinjun Chen

Hi Dims,

The same soap request works with my standalone program. The same method
toObject runs correctly gives correct result.

Regards,
Xinjun

On 5/3/07, Davanum Srinivas <[EMAIL PROTECTED]> wrote:


Xinjun,

can you run tcpmon to capture the soap request and use that xml with
your stand alone program to see if that works?

-- dims

On 5/3/07, Xinjun Chen <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
> I wrote a sample custom serializer/deserializer to serialize an object.
When
> I use a standalone program to test the serializer, it works fine. But
when I
> deploy the serializer as part of a web service and and invoke the web
> service through a SOAP request, I got the following null pointer
execption.
> I googled but didn't find the reason of this. Why does the NPE occur
only
> when I deploy the binder as part of the web service? I used the same
> SOAPEnvelope to test.
>
>
>
> java.lang.NullPointerException
> at
> org.apache.axiom.om.impl.llom.OMStAXWrapper.generateEvents(OMStAXWrap
> per.java:1115)
> at
> org.apache.axiom.om.impl.llom.OMStAXWrapper.next(OMStAXWrapper.java:9
>  11)
> at
> com.mycom.CreditCardPaymentRequestBinder.toObject(
CreditCardPaymentRequestBinder.java:138)
>
>
>
> The toObject method definition is as follows:
>
>  public CreditCardPaymentRequest toObject(QName qname, XMLStreamReader
> reader) throws XMLStreamException {
>   CreditCardPaymentRequest obj = new CreditCardPaymentRequest();
>
>   String rootElementName = qname.getLocalPart ();
>   String uri = qname.getNamespaceURI();
>
>   if(!rootNsUri.equals(uri)) {
>throw new XMLStreamException("Invalid namespace " + uri + ". Expected
> namespace uri is " + rootNsUri);
>   }
>
>   while(reader.hasNext()) {
>int type = reader.next(); // Line number: 138
>
>if(XMLStreamConstants.START_ELEMENT == type){
> String element = reader.getLocalName();
>
> if( rootLocalName.equals(element) ) {
>  continue;
> } else if( element.equals("cardNumber") ){
>  obj.setCardNumber(reader.getElementText());
> } else if( element.equals("expiryMonth") ) {
>  obj.setExpiryMonth(reader.getElementText());
> } else if( element.equals("expiryYear") ) {
>  obj.setExpiryYear(reader.getElementText());
> } else if( element.equals("brand") ) {
>  obj.setBrand(reader.getElementText());
> } else if( element.equals("totalAmount") ) {
>  obj.setTotalAmount(reader.getElementText());
> } else if( element.equals("currency") ) {
>  obj.setCurrency(reader.getElementText());
> } else if( element.equals("systemId") ) {
>  obj.setSystemId(reader.getElementText());
> } else if( element.equals("referenceNumber") ) {
>  obj.setReferenceNumber(reader.getElementText());
> } else if( element.equals("op") ) {
>  obj.setOp(reader.getElementText());
> } else {
>  throw new RuntimeException("Unexpected element " + element);
> }
>}
>
>if(XMLStreamConstants.END_ELEMENT == type){
> if(reader.getLocalName().equals(rootElementName)){
>  break;
> }
>}
>
>   }
>
>   return obj;
>  }
>
>
>
>
>
> Regards,
>
> Xinjun


--
Davanum Srinivas :: http://davanum.wordpress.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: [Axis2] AXIOM Custom Serializer/Deserializer

2007-05-03 Thread Davanum Srinivas

Xinjun,

can you run tcpmon to capture the soap request and use that xml with
your stand alone program to see if that works?

-- dims

On 5/3/07, Xinjun Chen <[EMAIL PROTECTED]> wrote:



Hi,

I wrote a sample custom serializer/deserializer to serialize an object. When
I use a standalone program to test the serializer, it works fine. But when I
deploy the serializer as part of a web service and and invoke the web
service through a SOAP request, I got the following null pointer execption.
I googled but didn't find the reason of this. Why does the NPE occur only
when I deploy the binder as part of the web service? I used the same
SOAPEnvelope to test.



java.lang.NullPointerException
at
org.apache.axiom.om.impl.llom.OMStAXWrapper.generateEvents(OMStAXWrap
per.java:1115)
at
org.apache.axiom.om.impl.llom.OMStAXWrapper.next(OMStAXWrapper.java:9
 11)
at
com.mycom.CreditCardPaymentRequestBinder.toObject(CreditCardPaymentRequestBinder.java:138)



The toObject method definition is as follows:

 public CreditCardPaymentRequest toObject(QName qname, XMLStreamReader
reader) throws XMLStreamException {
  CreditCardPaymentRequest obj = new CreditCardPaymentRequest();

  String rootElementName = qname.getLocalPart ();
  String uri = qname.getNamespaceURI();

  if(!rootNsUri.equals(uri)) {
   throw new XMLStreamException("Invalid namespace " + uri + ". Expected
namespace uri is " + rootNsUri);
  }

  while(reader.hasNext()) {
   int type = reader.next(); // Line number: 138

   if(XMLStreamConstants.START_ELEMENT == type){
String element = reader.getLocalName();

if( rootLocalName.equals(element) ) {
 continue;
} else if( element.equals("cardNumber") ){
 obj.setCardNumber(reader.getElementText());
} else if( element.equals("expiryMonth") ) {
 obj.setExpiryMonth(reader.getElementText());
} else if( element.equals("expiryYear") ) {
 obj.setExpiryYear(reader.getElementText());
} else if( element.equals("brand") ) {
 obj.setBrand(reader.getElementText());
} else if( element.equals("totalAmount") ) {
 obj.setTotalAmount(reader.getElementText());
} else if( element.equals("currency") ) {
 obj.setCurrency(reader.getElementText());
} else if( element.equals("systemId") ) {
 obj.setSystemId(reader.getElementText());
} else if( element.equals("referenceNumber") ) {
 obj.setReferenceNumber(reader.getElementText());
} else if( element.equals("op") ) {
 obj.setOp(reader.getElementText());
} else {
 throw new RuntimeException("Unexpected element " + element);
}
   }

   if(XMLStreamConstants.END_ELEMENT == type){
if(reader.getLocalName().equals(rootElementName)){
 break;
}
   }

  }

  return obj;
 }





Regards,

Xinjun



--
Davanum Srinivas :: http://davanum.wordpress.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]