我已经使用Intellij中的插件导入WSDL并生成连接端点所需的许多客户端文件。
终点需要WS-Address为真。
我当前的代码:
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*
*/
@Addressing(required=true) // ADDED TO TRY TO FIX WS-ADDRESSING
@WebServiceClient(name = "MYService", targetNamespace = "http://tempuri.org/", wsdlLocation = "http://mybasicvanilla.com/MYService.svc?wsdl")
public class MYService
extends Service
{
private final static URL MYSERVICE_WSDL_LOCATION;
private final static WebServiceException MYSERVICE_EXCEPTION;
private final static QName MYSERVICE_QNAME = new QName("http://tempuri.org/", "MYService");
static {
URL url = null;
WebServiceException e = null;
try {
url = new URL("http://mybasicvanilla.com/MYService.svc?wsdl");
} catch (MalformedURLException ex) {
e = new WebServiceException(ex);
}
MYSERVICE_WSDL_LOCATION = url;
MYSERVICE_EXCEPTION = e;
}
@WebEndpoint(name = "WSHttpBinding_IMYService")
public IMYService getWSHttpBindingIMYService() {
return super.getPort(new QName("http://tempuri.org/", "WSHttpBinding_IMYService"), IMYService.class,new javax.xml.ws.soap.AddressingFeature(true,true) );
}
@WebEndpoint(name = "WSHttpBinding_IMYService")
public IMYService getWSHttpBindingIMYService(WebServiceFeature... features) {
return super.getPort(new QName("http://tempuri.org/", "WSHttpBinding_IMYService"), IMYService.class, new javax.xml.ws.soap.AddressingFeature(true,true));
}
private static URL __getWsdlLocation() {
if (MYSERVICE_EXCEPTION!= null) {
throw MYSERVICE_EXCEPTION;
}
return MYSERVICE_WSDL_LOCATION;
}
}
当我尝试连接时堆栈消息:
Dec 22, 2017 9:04:05 AM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector] selectAlternatives
WARNING: WSP0075: Policy assertion "{http://www.w3.org/2006/05/addressing/wsdl}UsingAddressing" was evaluated as "UNKNOWN".
Dec 22, 2017 9:04:05 AM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector] selectAlternatives
WARNING: WSP0019: Suboptimal policy alternative selected on the client side with fitness "UNKNOWN".
我到目前为止的修复尝试是添加:
@Addressing(required=true)
上课。也尝试了:
javax.xml.ws.soap.AddressingFeature(true,true)
在两个Web端点上 - 但是错误持续存在。如果未设置为true,soapui也会失败。
看来我最初有类型,实际上是一个例外
Exception in thread "Thread-2" javax.xml.ws.soap.SOAPFaultException: MustUnderstand headers:[{http://www.w3.org/2005/08/addressing}Action] are not understood
我正确添加了:
new javax.xml.ws.soap.AddressingFeature(true,true)
正如ACV指出的其他消息是警告。