.NET WebService 与 Java 互通问题

C#编写的WebService,自己调用OK,Java侧调用无参接口报错:

faultString: Server did not recognize the value of HTTP Header SOAPAction:

接口的日志记录却正常。问Google,需要添加类属性:[SoapDocumentService(RoutingStyle = SoapServiceRoutingStyle.RequestElement)]

例如:

    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [SoapDocumentService(RoutingStyle = SoapServiceRoutingStyle.RequestElement)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class LoginService2013 : System.Web.Services.WebService
    {

再让Java侧调用无参接口,顺利通过。继续调用有参接口,被告知返回报错信息,查看接口日志,没有得到参数,Java侧确认调用无误,继续问Google,每个接口都需要添加这个属性:[SoapRpcMethod(Use = SoapBindingUse.Literal, Action = "http://tempuri.org/接口名称", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/")]

例如:

[WebMethod]
[SoapRpcMethod(Use = SoapBindingUse.Literal, Action = "http://tempuri.org/findUser", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/")]
public string findUser(string userID)
{

Java侧调用OK。

转载于:https://www.cnblogs.com/tails/p/3402299.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值