簡體   English   中英

如何使用SOAPUI將數據/請求發送到WSDL?

[英]How to send Data/request to WSDL with SOAPUI?

我又來了 也許有人可以幫助我。 我在這里閱讀了Stackoverflow上所有有關使用Soap發送請求的線程。 我在Google上搜索了很多教程,但沒有任何幫助。 所以,請幫我...我在這個問題上停留了大約一周....

問題/問題:

我有一個Soaphelper.java,它管理着我的android應用程序的所有連接內容。 到目前為止,一切都很好,但是現在我需要執行一個將數據發送到服務器的請求。 例如。 當我使用顯示名稱“開始”和EntryCodeNumber“ 10”發出請求並將其發送到服務器時,服務器將開始跟蹤時間。 我只需要將該數據發送到服務器上就更多了……后台中的所有工作都是由服務器完成的。

需求與響應SoapUI

在我的SoapHelper.java上,我將其稱為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;}

多數民眾贊成在請求:

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

我在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

我嘗試了很多事情,但在該問題上停留了大約一周的時間。 希望可以有人幫幫我。

編輯:SOAP_ACTION =“ http://tempuri.org/ITrackingService/ApplyTrackingData ”; METHOD =“ ApplyTrackingData”; NAMESPACE =“ http://tempuri.org/ ”; URL =“ https://xxxxxxxxxxx/Services/TrackingService.svc ”;

那就是wsdl

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

編輯“:

因此,在檢查了SOAP操作和端點之后,現在我得到了另一個失敗文本...

這是我整個肥皂調用部分

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;
}

那就是響應:

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

新要求

該請求如何:

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);

現在,我收到此消息:

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());
        }

在此處傳遞您的原始用戶名和密碼 在此處傳遞您的原始用戶名和密碼

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM