android调用wcf设计,如何在android上使用kso​​ap2调用WCF服务?

这是我的代码

import org.ksoap2.*;

import org.ksoap2.serialization.*;

import org.ksoap2.transport.*;

import android.app.Activity;

import android.os.Bundle;

import android.widget.TextView;

public class ksop2test extends Activity {

/** Called when the activity is first created. */

private static final String METHOD_NAME = "SayHello";

// private static final String METHOD_NAME = "HelloWorld";

private static final String NAMESPACE = "http://tempuri.org";

// private static final String NAMESPACE = "http://tempuri.org";

private static final String URL = "http://192.168.0.2:8080/HelloWCF/Service1.svc";

// private static final String URL = "http://192.168.0.2:8080/webservice1/Service1.asmx";

final String SOAP_ACTION = "http://tempuri.org/IService1/SayHello";

// final String SOAP_ACTION = "http://tempuri.org/HelloWorld";

TextView tv;

StringBuilder sb;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

tv = new TextView(this);

sb = new StringBuilder();

call();

tv.setText(sb.toString());

setContentView(tv);

}

public void call() {

try {

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

request.addProperty("name", "Qing");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(

SoapEnvelope.VER11);

envelope.dotNet = true;

envelope.setOutputSoapObject(request);

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

androidHttpTransport.call(SOAP_ACTION, envelope);

sb.append(envelope.toString() + "\n");//cannot get the xml request send

SoapPrimitive result = (SoapPrimitive)envelope.getResponse();

//to get the data

String resultData = result.toString();

// 0 is the first object of data

sb.append(resultData + "\n");

} catch (Exception e) {

sb.append("Error:\n" + e.getMessage() + "\n");

}

}

}

我可以成功访问.asmx服务,但是当我尝试调用wcf服务时

虚拟机说:

错误:

预期:END_TAG {http://schemas.xmlsoap.org/soap/envelope/}正文(位置:END_TAGhttp://schemas.xmlsoap.org/soap/envelope/)s:Fault> @ 1:712 in java.io.InputStreamReader@43ba6798

如何打印请求发送?

这是wcf wsdl:

它使用< xsd:schema>标签< wsdl:types>

而asmx使用< s:schema>标签< wsdl:types>

有什么不同?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值