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。