从JavaScript调用JAX-WS Web服务时的空参数
我有一个JAX-WS web服务,当它从任何客户端(即Java destkop应用程序)而不是从JavaScript被调用时,都可以正常工作 我的WS-interface如下所示:从JavaScript调用JAX-WS Web服务时的空参数,java,javascript,xml,web-services,Java,Javascript,Xml,Web Services,我有一个JAX-WS web服务,当它从任何客户端(即Java destkop应用程序)而不是从JavaScript被调用时,都可以正常工作 我的WS-interface如下所示: @WebService public interface LicenseService { @WebMethod String getLicense( @WebParam(name="coupon") String coupon, @WebParam(
@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);
<?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>
<getLicense xmlns="http://ws.licenseman.elevelcbt.eu/">
发送的信封
如下所示:
var request = new XMLHttpRequest();
request.open("POST", url, false);
request.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
request.send(envelope);
<?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>
<getLicense xmlns="http://ws.licenseman.elevelcbt.eu/">
SYcj1J9I
贝普
1234567890
该方法被调用(我可以在Java端跟踪),但所有传递的参数都为null。我的信封
格式/内容肯定有问题。好的,我知道了。
我需要更改我的信封
格式,使其看起来像这样(我在从java客户端成功调用WS时通过跟踪原始xml消息获得):
1111
贝普
xxxxxxx
JAX-WS似乎不喜欢这样的方法声明:
var request = new XMLHttpRequest();
request.open("POST", url, false);
request.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
request.send(envelope);
<?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>
<getLicense xmlns="http://ws.licenseman.elevelcbt.eu/">
并希望它是这样的:
<ns1:getLicense xmlns:ns1="http://ws.licenseman.elevelcbt.eu/">
谢谢您的帮助!在这个问题上花了几个小时之后,我按照您的建议解决了这个问题。除了我只在标签中添加了这个“ns1”,而不是将“soap:Envelope”更改为“soap-ENV:Envelope”,并进行了其他修改。谢谢。我也有同样的问题。C#客户完全疯了,因为他们像你的问题一样生成他们的请求。