NullPointerException with code generated from PayPal wsdl
---------------------------------------------------------

                 Key: XFIRE-915
                 URL: http://jira.codehaus.org/browse/XFIRE-915
             Project: XFire
          Issue Type: Bug
          Components: Aegis Module
    Affects Versions: 1.2.4
         Environment: Linux/Gentoo, Java 1.6, eclipse 3.2
            Reporter: Lado Kumsiashvili
         Assigned To: Dan Diephouse
         Attachments: generated.jar

I'd lige to use xFire FW for making PayPal SOAP API calls. So i've generated 
Java classes from PayPal wsdl and i have wroten a small test class, that uses 
this classes.
hier are links to PayPal wsdl and belonging XML Schemas:
PayPal Schema                tps://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl
eBL Base Components  https://www.sandbox.paypal.com/wsdl/eBLBaseComponents.xsd
Component Types            
https://www.sandbox.paypal.com/wsdl/CoreComponentTypes.xsd

I use in my client(see code below) some dummy params. They do not really 
matter. So i must receive some erros(Incorrect params, etc) as replay.
I have used debugger, and i receive a soap response, but then an 
NullPointerException occures. So a can not read any errors or transaction 
details in my programm.

.....
The code(I ve generated java classes with eclipse plugin and choose package 
name jira.xfire. If you choose another package name, please change this name on 
the test program too.


package jira.xfire;

import java.util.List;

import javax.xml.ws.Holder;

import xfire.jira.PayPalAPIInterface;
import xfire.jira.PayPalAPIInterfaceServiceClient;
import ebay.api.paypalapi.GetTransactionDetailsReq;
import ebay.api.paypalapi.GetTransactionDetailsRequestType;
import ebay.api.paypalapi.GetTransactionDetailsResponseType;
import ebay.apis.eblbasecomponents.CustomSecurityHeaderType;
import ebay.apis.eblbasecomponents.ErrorType;
import ebay.apis.eblbasecomponents.UserIdPasswordType;

/**
 * @author lado
 * 
 */
public class Main {

    /**
         * @param args
         */
    public static void main(String[] args) {
        GetTransactionDetailsRequestType r = new 
GetTransactionDetailsRequestType();
        r.setVersion("1.0");
        r.setTransactionID("87K78012VR671152J");// some dummy value
        PayPalAPIInterfaceServiceClient cc = new 
PayPalAPIInterfaceServiceClient();
        PayPalAPIInterface api = cc.getPayPalAPI();
        GetTransactionDetailsReq request = new GetTransactionDetailsReq();
        request.setGetTransactionDetailsRequest(r);

        CustomSecurityHeaderType requesterCredentials = new 
CustomSecurityHeaderType();
        UserIdPasswordType auth = new UserIdPasswordType();
        auth.setUsername("sdk-seller_api1.sdk.com");// We use some dummy
                                                        // user and password.
                                                        // But response must
                                                        // come
        auth.setPassword("12345678"); // and contain errors
        requesterCredentials.setCredentials(auth);
        Holder<CustomSecurityHeaderType> a2 = new 
Holder<CustomSecurityHeaderType>();
        a2.value = requesterCredentials;
        // call
        GetTransactionDetailsResponseType response = api.getTransactionDetails(
                request, requesterCredentials, a2);

        List<ErrorType> errors = response.getErrors();
        if (errors != null && errors.size() > 0) {
            System.out.println("\nERROR");
            for (ErrorType error : errors) {
                System.out.println("\nErrorCode: " + error.getErrorCode());
                System.out.println("\nShortErrorMessage: "
                        + error.getShortMessage());
                System.out.println("\nLongErrorMessage: "
                        + error.getLongMessage());
            }
        } else {
            System.out.println(response.getPaymentTransactionDetails()
                    .getPayerInfo());// some dummy code
        }
    }

}

and the Stacktrace:

Exception in thread "main" org.codehaus.xfire.XFireRuntimeException: Could not 
invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: 
Fault: java.lang.NullPointerException
org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException
        at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89)
        at org.codehaus.xfire.client.Client.onReceive(Client.java:386)
        at 
org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139)
        at 
org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
        at 
org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
        at 
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
        at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:75)
        at org.codehaus.xfire.client.Client.invoke(Client.java:335)
        at 
org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
        at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
        at $Proxy13.getTransactionDetails(Unknown Source)
        at jira.xfire.Main.main(Main.java:48)
Caused by: java.lang.NullPointerException
        at 
org.codehaus.xfire.aegis.AegisBindingProvider.getReadType(AegisBindingProvider.java:186)
        at 
org.codehaus.xfire.aegis.type.basic.BeanType.readObject(BeanType.java:152)
        at 
org.codehaus.xfire.aegis.AegisBindingProvider.readParameter(AegisBindingProvider.java:162)
        at 
org.codehaus.xfire.service.binding.ServiceInvocationHandler.readHeaders(ServiceInvocationHandler.java:181)
        at 
org.codehaus.xfire.client.ClientReceiveHandler.invoke(ClientReceiveHandler.java:32)
        at 
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
        at org.codehaus.xfire.client.Client.onReceive(Client.java:382)
        ... 10 more





The problem occures beacuse in the Method  public static Type 
getReadType(XMLStreamReader xsr, MessageContext context, Type type, TypeMapping 
tm)
null as type is passed. an then on the line 186 the code tries to read some 
member of type(null)
i've fixed this problem temporary with replaceing line 186 code
 if (!overrideTypeName.equals(type.getSchemaType())) with  if ( type!= null && 
!overrideTypeName.equals(type.getSchemaType()))
but i do not know if this solussion is good.

P.S.
I habe also atteched the all the generated code incl. my test Program Main.java

So long,
Lado




-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to