简体   繁体   中英

How to send Data/request to WSDL with SOAPUI?

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.

需求与响应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
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());
        }

在此处传递您的原始用户名和密码 pass your original username and Password here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM