android 调用 .net wcf 答疑

来源:互联网 发布:myeclipse mac版 编辑:程序博客网 时间:2024/06/05 16:21

错误1:

//09-17 23:49:02.488: I/System.out(20510):SoapFault - faultcode: 'a:ActionNotSupported' faultstring: '由于 //ContractFilter 在 EndpointDispatcher 不匹配,因此 Action //为“BsJDC.WcfService/WcfMobileInterface/GetServerDateTime”的消息无法在接收方处理。//这可能是由于协定不匹配(发送方和接收方 Action 不匹配)或发送方和接收方绑定/安全不匹配。//请检查发送方和接收方是否具有相同的协定和绑定(包括安全要求,如 Message、Transport、None)。' //faultactor: 'null' detail: null

问题分析:

    从异常中可以看出,android客户端调用wcf 接口 协议不一致。我之前产生这种异常,是因为我的代码如下:

final String _soapAction = 命名空间+类名+具体函数名 ;

问题解决: 修改以上_soapAction的值为 : 命名空间+接口文件名+具体函数名;


错误2:

10-05 08:42:03.895: W/System.err(4142): SoapFault - faultcode: 'a:InternalServiceFault' faultstring: 'String 引用没有设置为 String 的实例。10-05 08:42:03.895: W/System.err(4142): 参数名: s' faultactor: 'null' detail: org.kxml2.kdom.Node@4136b9f810-05 08:42:03.895: W/System.err(4142): at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:116)...省略10-05 08:42:03.895: E/Jdc_debug(4142): 错误信息(SoapFault):String 引用没有设置为 String 的实例。10-05 08:42:03.895: E/Jdc_debug(4142): 参数名: s
问题分析:   我产生错误的原因是解析参数错误。 
final SoapObject request = new SoapObject(NAMESPACE, methodName) ;request.addProperty("userCode", account);request.addProperty("userPwd", password) ;

以上是解决错误后的写法。之前错误是因为"userCode"、“userPwd“ 跟wcf 接口所 定义的参数大小写不一致。

以上皆是我今日开发过程中遇到的错误,可能大家也遇到一样错误,但是原因有可能不同。因此,这篇解决方案仅作参考。欢迎大家共享自己碰到问题,一起学习。

原创粉丝点击