从JavaScript调用JAX-WSWeb服务时参数为Null
Null parameters when calling a JAX-WS Web Service from JavaScript
我有一个JAX-WS web服务,当它从任何客户端(即Java destkop应用程序)而不是从JavaScript调用时,它都能正常工作。
我的WS界面如下:
@WebService
public interface LicenseService {
@WebMethod
String getLicense(
@WebParam(name="coupon") String coupon,
@WebParam(name="licenseCode") String licenseCode,
@WebParam(name="secret") String secret);
}
我用这样的javascript调用它:
var request = new XMLHttpRequest();
request.open("POST", url, false);
request.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
request.send(envelope);
并且发送的CCD_ 1看起来像这样:
<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getLicense xmlns="http://ws.licenseman.elevelcbt.eu/">
<coupon>SYcj1J9I</coupon>
<licenseCode>BEPRO</licenseCode>
<secret>1234567890</secret>
</getLicense>
</soap:Body>
</soap:Envelope>
该方法被调用(我可以在Java端跟踪),但所有传递的参数都为null。我的envelope
格式/内容一定有问题。
好的,我明白了。我需要将我的envelope
格式更改为这样(当我从java客户端成功调用WS时,我通过跟踪原始xml消息获得了它):
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header />
<SOAP-ENV:Body>
<ns1:getLicense xmlns:ns1="http://ws.licenseman.elevelcbt.eu/">
<coupon>1111</coupon>
<licenseCode>BEPRO</licenseCode>
<secret>xxxxxxx</secret>
</ns1:getLicense>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
JAX-WS似乎不喜欢这样的方法声明:
<getLicense xmlns="http://ws.licenseman.elevelcbt.eu/">
并且想要这样:
<ns1:getLicense xmlns:ns1="http://ws.licenseman.elevelcbt.eu/">
相关文章:
- 从JavaScript调用JAX-WSWeb服务时参数为Null
- ajax post在webapi中传递null参数
- Javascript-函数获取数组元素参数未定义/为null
- Ajax调用后控制器中的参数为Null
- 未能构造'Blob':提供的第一个参数为null,或者是无效的Array对象
- 当 JSON.stringify 时,ASP.NET MVC 控制器参数的 JSON 为 null
- fn.apply 与第一个参数 null 或未定义
- Function.prototype.bind with null 作为参数
- JavaScript null 参数使正则表达式匹配
- 在匿名回调中使用函数参数将返回 null/NaN
- Web API 控制器操作参数始终为 null
- javascript 返回 null 或 None 如果参数没有给函数
- 尝试将 Blob 传递给 C# 控制器时的 null 参数
- 使用AngularJS传递参数时,Resteasy@FormParam为null
- 为什么当中间参数为'null'
- Coffeescription出现奇怪问题-文本参数发送为null
- Angular$http发布到MVC操作,参数为null
- jQuery数据表-ASP.NET控制器参数始终为null
- MVC控制器'发布JSON数据时,s字符串[]参数为null
- Angular&ASP.NET MVC-当后端接收到参数时,该参数为null