【问题标题】:SOAP Client in Java - WSA AddressingJava 中的 SOAP 客户端 - WSA 寻址
【发布时间】:2018-06-04 13:27:17
【问题描述】:

我在 Intellij 中使用了一个插件来导入 WSDL 并生成连接端点所需的许多客户端文件。

端点要求 WS-Addressing 为真。

我当前的代码:

/**
 * 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 端点上 - 但错误仍然存​​在。如果 WS-Addressing 未设置为 true,SOAPUI 也会失败。

【问题讨论】:

标签: java web-services intellij-idea soap jax-ws


【解决方案1】:

看来我最初有一个类型,实际上得到了一个异常

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 指出的其他消息是警告。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-21
    • 2019-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多