0

i'm again. Maybe someone can help me. I've read all threads here on Stackoverflow that are about sending request with Soap and so on. I've googled und followed lots of tutorials but nothing help me. So pleaassee help me ... i'm stuck about one week on that issue ....

Issue/Problem:

I have a Soaphelper.java which managed all the connection stuff for my android app. All is wokring well so far but now i need to do a request which sends data to the server. For example. when i make a request with Displayname "Start" and EntryCodeNumber "10"and send this to the server, the server will start tracking the time. I've only to send that data to the server not more ... all the stuff in background is done by the server.

reqeust and response SoapUI

On my SoapHelper.java i made this to call that ApllyTrackingService

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("Username", convertToBase64user(user));
request.addProperty("Password", convertToBase64pass(pass));
request.addProperty("DisplayName", Displayname);
request.addProperty("EntryCodeNumber", EntryCode);
request.addProperty("EntryCodeNumber", EntryCode);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
response = (SoapObject) envelope.bodyIn;
return response;
} catch (Exception e) {
return response;}

The thats the request:

ApplyTrackingData{Username=xxxxxxxxxxxxxxxxxxx==; Password=xxxxxxxxxxxx; DisplayName=Start; EntryCodeNumber=10; }

And I get this on response=envelope.bodyIn

SoapFault - faultcode: 'a:ActionNotSupported' faultstring: 'Die Nachricht mit Action "http://tempuri.org/ITrackingService/ApplyTrackingData" kann aufgrund einer fehlenden ContractFilter-Übereinstimmung beim EndpointDispatcher nicht verarbeitet werden. Mögliche Ursachen: Vertragskonflikt (keine Action-Übereinstimmung zwischen Sender und Empfänger) oder ein Bindung/Sicherheit-Konflikt zwischen dem Sender und dem Empfänger.  Stellen Sie sicher, dass Sender und Empfänger über den gleichen Vertrag und die gleiche Bindung verfügen (einschließlich Sicherheitsanforderungen, z. B. "Message", "Transport", "None").' faultactor: 'null' detail: null

i've tried lots of things and i'm stuck about a week on that issue. Hope someone can help me.

EDIT: SOAP_ACTION = "http://tempuri.org/ITrackingService/ApplyTrackingData"; METHOD = "ApplyTrackingData"; NAMESPACE = "http://tempuri.org/"; URL = "https://xxxxxxxxxxx/Services/TrackingService.svc";

and thats the wsdl

http://cloud.progresso-group.de/Services/TrackingService.svc?singleWsdl

EDIT ":

so after checking the SOAP Action and Endpoints, now i've get a different failure text...

here is my whole Soap Calling part

SoapObject request2 = new SoapObject(NAMESPACE, METHOD_NAME);
request2.addProperty("Username", convertToBase64user(user));
request2.addProperty("Password", convertToBase64pass(pass));
request2.addProperty("DisplayName", Displayname);
request2.addProperty("EntryCodeNumber", EntryCode);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
Element headers[] = new Element[1];
headers[0] = new Element().createElement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security");
headers[0].setAttribute(envelope.env, "mustUnderstand", "1");
Element security = headers[0];
Element to = new Element().createElement(security.getNamespace(), "UsernameToken");
to.setAttribute("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", "Id", "UsernameToken-2");
Element action1 = new Element().createElement(security.getNamespace(), "Username");action1.addChild(Node.TEXT, user);

to.addChild(Node.ELEMENT, action1);
Element action2 = new Element().createElement(security.getNamespace(), "Password");
action2.setAttribute(null, "Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");action2.addChild(Node.TEXT, pass);
to.addChild(Node.ELEMENT, action2);headers[0].addChild(Node.ELEMENT, to);envelope.headerOut = headers;envelope.setOutputSoapObject(request2);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
    androidHttpTransport.debug = true;
    androidHttpTransport.call(SOAP_ACTION, envelope);
    response = (SoapObject) envelope.bodyIn;
 //   updateUiWithResult(response);
  return response;
} catch (Exception e) {
    return response;
}

and thats the response:

SoapFault - faultcode: 'a:InternalServiceFault' faultstring: 'value should not be null.Parametername: value' faultactor: 'null' detail: org.kxml2.kdom.Node@a0bec6a

NEW REQUEST

How about that request:

SoapObject request2 = new SoapObject(NAMESPACE, APPLYTRACKINGDATA_METHOD);
SoapObject apply =new SoapObject(NAMESPACE,"trackingAction");
PropertyInfo DisplayName1 = new PropertyInfo();
        DisplayName1.name="DisplayName";
        DisplayName1.setValue("Start");
        apply.addProperty(DisplayName1);
PropertyInfo EntryCodeNumber1 = new PropertyInfo();
        EntryCodeNumber1.name="EntryCodeNumber";
        EntryCodeNumber1.setValue(10);
        apply.addProperty(EntryCodeNumber1);
        request2.addSoapObject(apply);

......

 envelope.setOutputSoapObject(request2);

Now I've get this message:

SoapFault - faultcode: 'a:DeserializationFailed' faultstring: 'Der Formatierer hat beim Deserialisieren der Nachricht eine Ausnahme ausgelöst: Fehler beim Deserialisieren von Parameter http://tempuri.org/:trackingAction. Die InnerException-Nachricht war "Fehler in Zeile 1, Position 851. Das Element "http://tempuri.org/:trackingAction" enthält Daten eines Typs, der dem Namen "http://tempuri.org/:trackingAction" zugeordnet ist. Dem Deserialisierungsprogramm ist kein Typ bekannt, der diesem Namen zugeordnet ist. Verwenden Sie ggf. einen DataContractResolver, wenn Sie DataContractSerializer verwenden, oder fügen Sie den entsprechenden Typ für "trackingAction" der Liste der bekannten Typen hinzu. Verwenden Sie dazu z. B. das Attribut "KnownTypeAttribute", oder fügen Sie den Typ der an das Serialisierungsprogramm übergebenen Liste von bekannten Typen hinzu.".  Weitere Details finden Sie unter "InnerException".' faultactor: 'null' detail: org.kxml2.kdom.Node@6ac440d
Vitja
  • 21
  • 1
  • 7
  • Please post detail of SOAP_ACTION field and wsdl details – TestHat Jan 19 '16 at 10:57
  • i hope i've edit the right things :) – Vitja Jan 19 '16 at 12:30
  • Please check links [link1](http://stackoverflow.com/questions/7476837/contractfilter-mismatch-error) [link2](http://stackoverflow.com/questions/5487791/contractfilter-mismatch-at-the-endpointdispatcher-exception); these link may help – TestHat Jan 19 '16 at 13:02
  • This can be because: different contracts between client and sender. different binding between client and sender. The message security settings are not consistent between client and sender. check your config and svcinfo files – TestHat Jan 19 '16 at 13:11
  • thanks, with config you mean my soaphelper.java right ? where can i find the svcinfo files ? – Vitja Jan 19 '16 at 13:19
  • request2.addProperty("Username", convertToBase64user(user)); request2.addProperty("Password", convertToBase64pass(pass)); problem with these line as these are not the SOAP Message Property in wsdl, you can't add them as Property. – TestHat Jan 20 '16 at 06:09
  • There is some issue request. You can try Passing Hard coded request if its work fine then we can check the problem. Try it – TestHat Jan 20 '16 at 06:14
  • how about that request ? edit to first post NEW REQUEST – Vitja Jan 20 '16 at 08:44
  • Posted my code, update username and Password; let's see what happens – TestHat Jan 20 '16 at 10:02

2 Answers2

0
SoapObject apply = new SoapObject(NAMESPACE, METHOD_NAME);
        PropertyInfo DisplayName1 =new PropertyInfo();
        DisplayName1.name="DisplayName";
        DisplayName1.setValue("Start");
        apply.addProperty(DisplayName1);


        PropertyInfo EntryCodeNumber1 = new PropertyInfo();
        EntryCodeNumber1.name="EntryCodeNumber";
        EntryCodeNumber1.setValue(10);
        apply.addProperty(EntryCodeNumber1);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);


        // create header
        Element[] header = new Element[1];
        header[0] = new Element().createElement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd","Security");
        header[0].setAttribute(null, "mustUnderstand","1");

        Element usernametoken = new Element().createElement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "UsernameToken");
        usernametoken.setAttribute(null, "Id", "UsernameToken-1");
        header[0].addChild(Node.ELEMENT,usernametoken);

        Element username = new Element().createElement(null, "n0:Username");
        username.addChild(Node.IGNORABLE_WHITESPACE,"PASSYOURUSERNAMEHERE");
        usernametoken.addChild(Node.ELEMENT,username);

        Element pass = new Element().createElement(null,"n0:Password");
        pass.setAttribute(null, "Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
        pass.addChild(Node.TEXT, "PASSYOURPASSWORDHERE");

        usernametoken.addChild(Node.ELEMENT, pass);


        // add header to envelope
        envelope.headerOut = header;   


        envelope.dotNet = true;
        envelope.bodyOut = apply;
        envelope.setOutputSoapObject(apply);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);


        try 
        {
            androidHttpTransport.debug = true;
            androidHttpTransport.call(SOAP_ACTION, envelope);

            SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
            Log.i(response.toString());
        } 
        catch (SoapFault e)
        {
            e.printStackTrace();
        }
        catch (Exception e) 
        {
            e.printStackTrace();
            Log.d("Exception Generated", ""+e.getMessage());
        }
TestHat
  • 175
  • 5
  • first of all thanks :) i get this message on Log.i(response.to()); Error:(136, 16) error: no suitable method found for i(String) method Log.i(String,String) is not applicable (actual and formal argument lists differ in length) method Log.i(String,String,Throwable) is not applicable (actual and formal argument lists differ in length) – Vitja Jan 20 '16 at 10:18
  • update Log.i(response.toString()); ---> Log.i("output",response.toString()) Sorry miss that – TestHat Jan 20 '16 at 10:34
  • OR return response OR return response.toString() here – TestHat Jan 20 '16 at 10:42
  • on this line its jumping out SoapPrimitive response2 = (SoapPrimitive)envelope.getResponse(); Androidstudio says to me that a return statement is missing after second catch exeption. After second catch exeption i added a return null; .... now when calling SoapPrimitive response2 = (SoapPrimitive)envelope.getResponse(); it directly jump to return null ... somehow it skips the catch functions ... – Vitja Jan 20 '16 at 10:52
  • Moreover Log.i is not even performed... When i was programming first time with SoapPrimitive it always stops on that step. the only way that was working for was the response = (SoapObject) envelope.bodyIn; mehtod – Vitja Jan 20 '16 at 10:55
  • use response = (SoapObject) envelope.bodyIn; return response .toString() } catch (Exception e) { return e;} – TestHat Jan 20 '16 at 11:00
  • thanks two things: at "PASSYOURPASSWORDHERE" and "PASSYOURUSERNAMEHERE" shoud i pass username as normal string or as convertToBase64user(username) ? and second things. thats the response i get now: SoapFault - faultcode: 'a:InternalServiceFault' faultstring: 'value should not be null. Parametername: value' faultactor: 'null' detail: org.kxml2.kdom.Node@b655854 – Vitja Jan 20 '16 at 11:12
  • thats the SoapUI requestbody: – Vitja Jan 20 '16 at 11:23
  • Start 10 Maybe trackingActions is missing ? – Vitja Jan 20 '16 at 11:24
  • In soapUI, for ApplyTrackingAction add a basic Authentication with username and Password – TestHat Jan 20 '16 at 11:43
  • do you mean that ? test – Vitja Jan 20 '16 at 13:00
  • in my android app/ SoapConnectionHelper.java i've already had the basic auth header or ? – Vitja Jan 20 '16 at 13:20
0

pass your original username and Password here pass your original username and Password here

TestHat
  • 175
  • 5
  • on SoapUI all is working fine. I can send the EntryCodeNumber and i get the right answer. In SoapUI I've already had a basic auth header. IT not working on my Android app :/ ... with response = (SoapObject) envelope.bodyIn; return response.toString();} i get response = null – Vitja Jan 20 '16 at 13:54
  • thats the request I'm sending with your code: ApplyTrackingAction{DisplayName=Start; EntryCodeNumber=10; } ... envelope.bodyOut is the same as request and as response i get null and as Exeption i get: SoapFault - faultcode: 'a:InternalServiceFault' faultstring: 'value should not be null. Parametername: value' faultactor: 'null' detail: org.kxml2.kdom.Node@6035ac3 – Vitja Jan 20 '16 at 13:55
  • it seems that the request " apply " isnt recognized. I have uncommented the request part and get the same response with same exeption. Moreover i've deleted the DisplayName and EntryCodeNumber part from SoapUI and I get the same response with same exeption. The apply request isnt working – Vitja Jan 20 '16 at 14:21
  • what do you think should i try it with http post method ? – Vitja Jan 21 '16 at 16:48