android连接wcf问题求大神解决

WOXIANG11 2013-05-07 03:51:12
public class HelloService implements ISoapService{

private static final String NameSpace = "http://tempuri.org/";
private static final String URL = "http://192.168.1.86:80/AndroidService.svc";
private static final String SOAP_ACTION = "http://tempuri.org/fnTest";
private static final String MethodName = "fnTest";
private static HelloService HomeLinkManager;
public static HelloService getInstance() {
if (HomeLinkManager == null) {
HomeLinkManager = new HelloService();
}
return HomeLinkManager;
}

public HelloService() {
}


public SoapObject LoadResult() {
SoapObject request = new SoapObject(NameSpace, MethodName); // example方法中有一个String的参数,这里将“android client”传递到example中
request.addProperty("inputCommand", "oh"); // 获得序列化的Envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true; envelope.bodyOut = request; // Android传输对象
HttpTransportSE transport = new HttpTransportSE(URL);
transport.debug = true; // 调用WebService
try { transport.call(SOAP_ACTION, envelope);
}
catch (IOException e) { // TODO Auto-generated catch block
e.getMessage();
}
catch (XmlPullParserException e) { // TODO Auto-generated catch block
e.getMessage(); } try {
if (envelope.getResponse() != null) {
envelope.bodyIn.toString(); }
} catch (SoapFault e) { // TODO Auto-generated catch block
e.getMessage(); }



SoapObject result = (SoapObject) envelope.bodyIn;
//System.out.println(result.toString());
//SoapObject result =(SoapObject) envelope.getResponse();
return result;
}
网上复制过来的代码使用,但是执行到 transport.call(SOAP_ACTION, envelope); 就会报错,说http404,但是我明明在iis里面可以访问地址的啊!弄了2天都不知哪里有问题请问有大神回答吗
...全文
96 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
WOXIANG11 2013-05-09
  • 打赏
  • 举报
回复
执行到transport.call(SOAP_ACTION, envelope); 报错Unexpected token (position:TEXT {"name":"Ian","a...@1:24 in java.io.InputStreamReader@41014750) 现在变了这个错误了怎么没人啊
WOXIANG11 2013-05-08
  • 打赏
  • 举报
回复
怎么没人啊,难道发错地方了吗

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧