0

I am using ksoap to connect to CrmDiscoveryService on Android, here comes the problem:

SoapFault - faultcode: 'soap:server' faultstring: 'Server was unable to process request.' faultactor: 'null' detail: org.kxml2.kdom.Node@4061bd00

//here is namespace,endpoint,soapaction and methodname

public final static String DISCOVERY_NAMESPACE = "http://schemas.microsoft.com/crm/2007/CrmDiscoveryService/";

public final static String DISCOVERY_ENDPOINT_URL = "https://dev.crm5.dynamics.com/MSCRMServices/2007/Passport/CrmDiscoveryService.asmx";

public final static String SOAPACTION = "http://schemas.microsoft.com/crm/2007/CrmDiscoveryService/Execute";

private String MethodName = "Execute";

//below is the code connectting to crmdiscoveryservice

SoapObject rpc = new SoapObject(DISCOVERY_NAMESPACE, MethodName);

RetrievePolicyRequest retrievePolicyRequest = new RetrievePolicyRequest();

PropertyInfo info = new PropertyInfo();

info.name = "parameters";
info.type = retrievePolicyRequest.getClass();
info.setValue(retrievePolicyRequest);
rpc.addProperty(info);

HttpTransportSE ht = new HttpTransportSE(DISCOVERY_ENDPOINT_URL);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

envelope.dotNet = true;
envelope.encodingStyle = "utf-8";
envelope.setOutputSoapObject(rpc);

try {
    ht.call(SOAPACTION, envelope);

    if (envelope.getResponse() != null) {
        SoapPrimitive response = (SoapPrimitive) envelope.bodyIn;
        Log.e(tag, response.toString());
    }

} catch (IOException e) {
         e.printStackTrace();
} catch (XmlPullParserException e) {
    e.printStackTrace();
}

And i defined RetrievePolicyRequest myself. I have tried many times, still have this problem, any people know how to solve this problem?

Thank you!

1 Answers1

0

Here are the following that I think could be going wrong with you code.

  1. You may be using the wrong propertyinfo.name. For example looking at htt(REMOVE THIS)ps://dev.crm5.dynamics.com/MSCRMServices/2007/Passport/CrmDiscoveryService.asmx?WSDL , it sure looks like you want info.name = "Request"; . If this is indeed the case, then your going to have to modify your complex type class to be request as well.

  2. Although you are adding a class as the type of the property with info.type = retrievePolicyRequest.getClass(); this (for some reason I still don't understand) isn't enough. You must also "map" this class to your envelope. Meaning that you should have

    envelope.dotNet = "true";
    envelope.encodingStyle = "utf-8";
    envelope.setOutputSoapObject(rpc);
    envelope.addMapping(DISCOVERY_NAMESPACE, "Request", new Request().getClass());
    

Those are the things I see immediately, here are some things that will deffinately help you (they helped me a ton for soap calls like this).

First, you have to check out soapUI. You can start a 14 day trial. With it, you can point soapUI to a wsdl url, and it will allow you to test the method calls (so you can easily see what your request should look like, and can also see how the returned xml looks). http://www.soapui.org/ . This program will literally spell out what the method is, what the namespace is, what the url is, if it is using soap11 or soap12... etc. USE THIS!!

Second, for complex types like this, you should really see this tutorial: http://seesharpgears.blogspot.com/2010/10/ksoap-android-web-service-tutorial-with.html . I went from bashing my head against the keyboard, to reading this tutorial and having my code work first try (that never happens!).

Good luck, and if you need more help just post! =)

  • Joey