是否有可能从Android的调用WsHttpBinding的? [英] Is it possible to call WSHTTPBINDING from android?
本文介绍了是否有可能从Android的调用WsHttpBinding的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
私有静态最后弦乐SOAP_ACTION =http://tempuri.org/IService1/HelloTest;
私有静态最后弦乐METHOD_NAME =HelloTest;
私有静态最后弦乐NAMESPACE =http://tempuri.org/;
私有静态最后字符串的URL =; //空白隐私
SoapObject请求=新SoapObject(命名空间METHOD_NAME);
//request.addProperty("Celsius,32);
SoapSerializationEnvelope包=新SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = TRUE;
envelope.setOutputSoapObject(要求);
HttpTransportSE HT =新HttpTransportSE(URL);
尝试 {
ht.call(SOAP_ACTION,包);
最终SoapPrimitive响应=(SoapPrimitive)envelope.getResponse();
最终的字符串str = response.toString();
Toast.makeText(MainActivity.this,STR,5000).show();
fetch_service.setText(STR);
}
赶上(例外五){
e.printStackTrace();
}
我要打电话给我的方法(你好测试)。其结果将是喂试验回报。但这个样本正在为基本的HTTP绑定,但不工作的WsHttpBinding的。
解决方案
元素e =新元素();
e.setName(到);
e.setNamespace(http://www.w3.org/2005/08/addressing);
e.addChild(Node.TEXT,
你的URL HERE);
元素E1 =新元素();
e1.setName(行动);
e1.setNamespace(http://www.w3.org/2005/08/addressing);
e1.addChild(Node.TEXT,
http://tempuri.org/IService1/HelloTest);
request.addProperty(摄氏,32);
//使用VER12代替VER11
SoapSerializationEnvelope包=新SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.dotNet = TRUE;
//添加HederOut到信封
envelope.headerOut =新的元素[] {E,E1};
envelope.setOutputSoapObject(要求);
private static final String SOAP_ACTION = "http://tempuri.org/IService1/HelloTest";
private static final String METHOD_NAME = "HelloTest";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = ""; //blank for privacy
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
//request.addProperty("Celsius", "32");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
HttpTransportSE ht = new HttpTransportSE(URL);
try {
ht.call(SOAP_ACTION, envelope);
final SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
final String str = response.toString();
Toast.makeText(MainActivity.this, str, 5000).show();
fetch_service.setText(str);
}
catch (Exception e) {
e.printStackTrace();
}
I want to call my method (Hello Test). The result will be hello test return. But this sample is working for basic http binding but not working for wshttpbinding.
解决方案
Element e = new Element();
e.setName("To");
e.setNamespace("http://www.w3.org/2005/08/addressing");
e.addChild(Node.TEXT,
"your URL HERE");
Element e1 = new Element();
e1.setName("Action");
e1.setNamespace("http://www.w3.org/2005/08/addressing");
e1.addChild(Node.TEXT,
"http://tempuri.org/IService1/HelloTest");
request.addProperty("Celsius", "32");
// use VER12 instead of VER11
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.dotNet=true;
// add HederOut to envelope
envelope.headerOut = new Element[] { e, e1 };
envelope.setOutputSoapObject(request);
这篇关于是否有可能从Android的调用WsHttpBinding的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文