Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Soap 黑莓香皂消费量_Soap_Blackberry - Fatal编程技术网

Soap 黑莓香皂消费量

Soap 黑莓香皂消费量,soap,blackberry,Soap,Blackberry,我第一次尝试编写一个黑莓应用程序,该应用程序使用嵌入JSON数据的SOAP web服务,并且遇到了一个比我需要解决的时间更长的挑战。我非常感谢你在这方面的帮助。多谢各位 以下是Web服务请求的结构: <logonrequest> { "userid":"username", "password":"password", "Timestamp":"" } </logonrequest> { “userid”:“username”,

我第一次尝试编写一个黑莓应用程序,该应用程序使用嵌入JSON数据的SOAP web服务,并且遇到了一个比我需要解决的时间更长的挑战。我非常感谢你在这方面的帮助。多谢各位

以下是Web服务请求的结构:

<logonrequest>
    {
    "userid":"username",
    "password":"password",
    "Timestamp":""
    }
</logonrequest>

{
“userid”:“username”,
“密码”:“密码”,
“时间戳”:”
}
以下是Web服务响应的结构:

<return>
    {
        "userid":"username",
        "displayName":"Firstname Lastname",
        "accountBalance":0.0,
        "statusCode":"0|SUCCESS",
        "statusDesc":"Logon Success",
        "sessionid":"12047CC560484D21BD328EC8F22814ED",
        "lastTransactionTime":"20131130234326"
    }
</return>

{
“userid”:“username”,
“displayName”:“Firstname Lastname”,
“账户余额”:0.0,
“状态码”:“0 |成功”,
“statusDesc”:“登录成功”,
“会话ID”:“12047CC560484D21BD328EC8F22814ED”,
“lastTransactionTime”:“2013113024326”
}
下面是我的黑莓Java代码: package com.abc.app

import java.io.IOException;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransport;
import org.xmlpull.v1.XmlPullParserException;
import a1.org2b.json.me.JSONException;
import a1.org2b.json.me.JSONObject;

public class MySoapAttempt extends MainScreen {
    String serviceUrl = "http://www.abcappserver.tk:30740/abcJSONWebApp/abcJSONWebServiceV1?wsdl";
    String serviceNamespace = "http://webapps.abc.abcConnect.com/";
    String soapAction = "http://webapps.abc.abcConnect.com/logonrequest";
    HttpTransport transport = new HttpTransport(serviceUrl + "/;deviceside=false;ConnectionType=mds-public");

    SoapObject rpc = new SoapObject(serviceNamespace, "logonrequest");
//  SoapObject result;
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

    public MySoapAttempt() {
        envelope.bodyOut = rpc;

        JSONObject container = new JSONObject();
        try {
            container.put("userid", "username");
            container.put("password", "password");
            container.put("Timestamp", "");
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        rpc.addProperty("logonrequest", container.toString());
        envelope.setOutputSoapObject(rpc);

        try {
                envelope.dotNet = false;
                envelope.encodingStyle = SoapSerializationEnvelope.XSD;
                transport.debug = true;
                transport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

                transport.call(soapAction, envelope);
                SoapPrimitive result = (SoapPrimitive)envelope.getResponse();
                Dialog.alert(result.toString());
                System.out.println("------=========-------- "+result);
        } catch (IOException e) {
            System.out.println("======= IOException =======");
            System.out.println(e.getMessage());
                e.printStackTrace();
        } catch (XmlPullParserException e) {
            System.out.println("======= XmlPullParserException =======");
            System.out.println(e.getMessage());
            System.out.println(e.toString());
                e.printStackTrace();
        } catch (Exception e) {
            System.out.println("======= General Exception =======");
            System.out.println(e.getMessage());
            System.out.println(e.toString());
                e.printStackTrace();
        } finally {
            System.out.println("=== >>> REQUEST: " + transport.requestDump);
            System.out.println("===========================================");
            System.out.println("=== >>> REQUEST: " + transport.responseDump);
            add(new LabelField("Welcome To My SOAP Attempt"));
        }
    }

}
import java.io.IOException;
导入net.rim.device.api.ui.component.Dialog;
导入net.rim.device.api.ui.component.LabelField;
导入net.rim.device.api.ui.container.main屏幕;
导入org.ksoap2.SoapEnvelope;
导入org.ksoap2.serialization.PropertyInfo;
导入org.ksoap2.serialization.SoapObject;
导入org.ksoap2.serialization.SoapPrimitive;
导入org.ksoap2.serialization.SoapSerializationEnvelope;
导入org.ksoap2.transport.HttpTransport;
导入org.xmlpull.v1.XmlPullParserException;
导入a1.org2b.json.me.JSONException;
导入a1.org2b.json.me.JSONObject;
公共类mysoapattmpt扩展主屏幕{
字符串serviceUrl=”http://www.abcappserver.tk:30740/abcJSONWebApp/abcJSONWebServiceV1?wsdl";
字符串serviceNamespace=”http://webapps.abc.abcConnect.com/";
字符串soapAction=”http://webapps.abc.abcConnect.com/logonrequest";
HttpTransport传输=新的HttpTransport(serviceUrl+“/;deviceside=false;ConnectionType=mds public”);
SoapObject rpc=新的SoapObject(serviceNamespace,“logonrequest”);
//目标结果;
SoapSerializationEnvelope=新的SoapSerializationEnvelope(SoapEnvelope.VER11);
公共mysoapatt(){
envelope.bodyOut=rpc;
JSONObject容器=新的JSONObject();
试一试{
container.put(“userid”、“username”);
容器。放置(“密码”、“密码”);
容器。放置(“时间戳”);
}捕获(JSONException e){
//TODO自动生成的捕捉块
e、 printStackTrace();
}
addProperty(“logonrequest”,container.toString());
信封.setOutputSoapObject(rpc);
试一试{
envelope.dotNet=false;
envelope.encodingStyle=SoapSerializationEnvelope.XSD;
transport.debug=true;
transport.setXmlVersionTag(“”);
传输呼叫(soapAction,信封);
SoapPrimitive结果=(SoapPrimitive)信封.getResponse();
Dialog.alert(result.toString());
System.out.println(“--------==============================+结果);
}捕获(IOE异常){
System.out.println(“==========IOException==========”);
System.out.println(e.getMessage());
e、 printStackTrace();
}catch(XMLPullParseRexE){
System.out.println(“==========XmlPullParserException==========”;
System.out.println(e.getMessage());
System.out.println(例如toString());
e、 printStackTrace();
}捕获(例外e){
System.out.println(“==========一般异常========”);
System.out.println(e.getMessage());
System.out.println(例如toString());
e、 printStackTrace();
}最后{
System.out.println(“==>>>请求:“+transport.requestDump”);
System.out.println(“======================================================================”);
System.out.println(“==>>>请求:“+transport.responseDump”);
添加(新LabelField(“欢迎使用我的SOAP尝试”);
}
}
}
下面是Web服务控制台的结构:

[127779.77] AM: Starting abc
[127779.79] AM: Started abc(483)
[127779.79] AM: Foreground is set: abc(483)
...
[127793.06] ======= XmlPullParserException =======
[127793.06] expected: END_TAG {http://schemas.xmlsoap.org/soap/envelope/}Body (position:END_TAG </{http://schema
[127793.06] s.xmlsoap.org/soap/envelope/}S:Fault>@1:324 in java.io.InputStreamReader@267621d3) 
[127793.06] org.xmlpull.v1.XmlPullParserException: expected: END_TAG {http://schemas.xmlsoap.org/soap/envelope/}
[127793.06] Body (position:END_TAG </{http://schemas.xmlsoap.org/soap/envelope/}S:Fault>@1:324 in java.io.InputS
[127793.06] treamReader@267621d3) 
[127793.06] No stack trace
[127793.06] === >>> REQUEST: <?xml version="1.0" encoding="UTF-8"?><v:Envelope xmlns:i="http://www.w3.org/2001/X
[127793.06] MLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/so
[127793.06] ap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/
[127793.06] envelope/"><v:Header /><v:Body><n0:logonrequest id="o0" c:root="1" xmlns:n0="http://webapps.abc.
[127793.06] abcConnect.com/"><logonrequest i:type="d:string">{"userid":"username","password":"password","Timesta
[127793.06] mp":""}</logonrequest></n0:logonrequest></v:Body></v:En
[127793.06] velope>
[127793.06] 
[127793.06] ===========================================
[127793.07] === >>> REQUEST: <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.o
[127793.07] rg/soap/envelope/"><S:Body><S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope"><faultcode>S
[127793.07] :Client</faultcode><faultstring>Cannot find dispatch me
[127793.07] thod for {http://webapps.abc.abcConnect.com/}logonrequest</faultstring></S:Fault></S:Body></S:E
[127793.07] nvelope>
[127779.77]上午:启动abc
[127779.79]上午:开始abc(483)
[127779.79]上午:设置前景:abc(483)
...
[127793.06]=======XmlPullParserException=======
[127793.06]预期:结束标签{http://schemas.xmlsoap.org/soap/envelope/}正文(位置:java.io中的END_标记@1:324)。InputStreamReader@267621d3) 
[127793.06]org.xmlpull.v1.XmlPullParserException:应为:END_标记{http://schemas.xmlsoap.org/soap/envelope/}
[127793.06]主体(在java.io.InputS中的位置:END_标记@1:324
[127793.06] treamReader@267621d3) 
[127793.06]没有堆栈跟踪
[127793.06]==>>>请求:{“userid”:“username”,“password”:“password”,“Timesta”
[127793.06]mp:“”}
[127793.06] 
[127793.06] ===========================================
[127793.07]==>>>请求:S
[127793.07]:客户找不到我
[127793.07]{http://webapps.abc.abcConnect.com/}登录请求

我从控制台输出中注意到,我的请求字符串似乎格式不正确。我如何让它发送一个看起来与上面要求的示例请求完全相同的请求?谢谢。

我不能从SOAP的角度回答这个问题,因为我对SOAP一无所知。我对XML不是很在行。但从XML的角度来看,您的XML似乎格式不正确。如果要传递不应解释为XML的数据,请使用CDATA。否则,XML解析器将尝试将JSON字符解释为XML,而不是XML

有关更多信息,请参见此处:


据我所知,当您使用SOAP时,您需要使用XML,因此另一种选择是将数据格式化为XML。应该可以创建一个等价的XML结构来包含JSON数据,并且可以正确解析

问题是什么?@Krsteev,我编辑了这篇文章,想问一个实际的问题。谢谢你的观察。