WSIT/Metro 不理解安全 SOAP 标头

发布于 2024-08-27 10:23:41 字数 5444 浏览 4 评论 0原文

我正在使用 WSIT/Metro 创建一个简单的 Web 服务。当客户端尝试使用简单的用户名/密码身份验证方案进行连接时,我在服务器上收到以下错误:

2010.03.31. 19:10:33 com.sun.xml.ws.protocol.soap.MUTube getMisUnderstoodHeaders
INFO: Element not understood={http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security

我不知道如何使 WSIT 理解安全块。

我从客户端收到的请求:

<?xml version="1.0" encoding="http://www.w3.org/2003/05/soap-envelope" standalone="no"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
    <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
            soapenv:mustUnderstand="true">
            <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
                wsu:Id="UsernameToken-1">
                <wsse:Username>admin</wsse:Username>
                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">admin</wsse:Password>
            </wsse:UsernameToken>
        </wsse:Security>
        <wsa:To>http://localhost:11122/services/TopJtapiRemoteMethods</wsa:To>
        <wsa:MessageID>urn:uuid:D5C576F83D74F761311270055433217</wsa:MessageID>
        <wsa:Action>urn:hasCallPolling</wsa:Action>
    </soapenv:Header>
    <soapenv:Body />
</soapenv:Envelope>

服务器的 WSDL:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
    targetNamespace="http://soapserver.topjtapi.cti.topdesk.com"
    xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
    xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
    xmlns:ns="http://soapserver.topjtapi.cti.topdesk.com"
    xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12/">
    <wsp:Policy wsu:Id="PasswordAuthPolicy">
        <wsp:All>
            <sp:SupportingTokens>
                <wsp:Policy>
                    <sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
                        <wsp:Policy>
                            <sp:WssUsernameToken10 />
                        </wsp:Policy>
                    </sp:UsernameToken>
                </wsp:Policy>
            </sp:SupportingTokens>
        </wsp:All>
    </wsp:Policy>

    <wsdl:types>
        <!-- ... -->
    </wsdl:types>
    <wsdl:message name="incomingCallRequest">
        <!-- ... -->
    </wsdl:message>
    <wsdl:portType name="TopJtapiRemoteMethodsPortType">
        <!-- ... -->
    </wsdl:portType>
    <wsdl:binding name="TopJtapiRemoteMethodsSoap12Binding" type="ns:TopJtapiRemoteMethodsPortType">
        <wsp:PolicyReference URI="#PasswordAuthPolicy"/>
        <wsoap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="hasCallPolling">
            <!-- ... -->
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="TopJtapiRemoteMethods">
        <wsdl:port name="TopJtapiRemoteMethodsHttpSoap12Endpoint" binding="ns:TopJtapiRemoteMethodsSoap12Binding">
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

我的代码,设置服务器:

import java.io.InputStream;
import java.util.Collections;

import javax.jws.WebService;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.ws.Endpoint;
import javax.xml.ws.Holder;

import com.topdesk.cti.topjtapi.soapserver2.HasCallPollingResponse;
import com.topdesk.cti.topjtapi.soapserver2.TopJtapiRemoteMethodsPortType;

public class EndpointTester {

    @WebService(endpointInterface = "com.topdesk.cti.topjtapi.soapserver2.TopJtapiRemoteMethodsPortType")
    private static final class MockImplementation implements TopJtapiRemoteMethodsPortType {
        @Override
        public HasCallPollingResponse hasCallPolling() {
            return null;
        }
    }

    /**
     * @see javax.xml.ws.soap.SOAPBinding#SOAP12HTTP_BINDING
     * @see https://jax-ws.dev.java.net/2.1.7/docs/soap12.html
     */
    private static final String SOAP12_BINDING_ID = "http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/";

    public static void main(String[] args) throws Exception {
        Endpoint endpoint = Endpoint.create(SOAP12_BINDING_ID, new MockImplementation());
        InputStream wsdlStream = EndpointTester.class.getResourceAsStream("/topjtapi-webapp/wsdl/TopJtapiRemoteMethods.wsdl");
        endpoint.setMetadata(Collections.<Source> singletonList(new StreamSource(wsdlStream, "http://soapserver.topjtapi.cti.topdesk.com")));
        endpoint.publish("http://localhost/services/TopJtapiRemoteMethods");

        System.in.read();
    }
}

I'm using WSIT/Metro to create a simple web-service. I'm getting the following error on the server when a client tries to connect with a simple username/passowrd authentication scheme:

2010.03.31. 19:10:33 com.sun.xml.ws.protocol.soap.MUTube getMisUnderstoodHeaders
INFO: Element not understood={http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security

I have no idea how to make WSIT understand the Security block.

The request I get from the client:

<?xml version="1.0" encoding="http://www.w3.org/2003/05/soap-envelope" standalone="no"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
    <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
            soapenv:mustUnderstand="true">
            <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
                wsu:Id="UsernameToken-1">
                <wsse:Username>admin</wsse:Username>
                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">admin</wsse:Password>
            </wsse:UsernameToken>
        </wsse:Security>
        <wsa:To>http://localhost:11122/services/TopJtapiRemoteMethods</wsa:To>
        <wsa:MessageID>urn:uuid:D5C576F83D74F761311270055433217</wsa:MessageID>
        <wsa:Action>urn:hasCallPolling</wsa:Action>
    </soapenv:Header>
    <soapenv:Body />
</soapenv:Envelope>

The server's WSDL:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
    targetNamespace="http://soapserver.topjtapi.cti.topdesk.com"
    xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
    xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
    xmlns:ns="http://soapserver.topjtapi.cti.topdesk.com"
    xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12/">
    <wsp:Policy wsu:Id="PasswordAuthPolicy">
        <wsp:All>
            <sp:SupportingTokens>
                <wsp:Policy>
                    <sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
                        <wsp:Policy>
                            <sp:WssUsernameToken10 />
                        </wsp:Policy>
                    </sp:UsernameToken>
                </wsp:Policy>
            </sp:SupportingTokens>
        </wsp:All>
    </wsp:Policy>

    <wsdl:types>
        <!-- ... -->
    </wsdl:types>
    <wsdl:message name="incomingCallRequest">
        <!-- ... -->
    </wsdl:message>
    <wsdl:portType name="TopJtapiRemoteMethodsPortType">
        <!-- ... -->
    </wsdl:portType>
    <wsdl:binding name="TopJtapiRemoteMethodsSoap12Binding" type="ns:TopJtapiRemoteMethodsPortType">
        <wsp:PolicyReference URI="#PasswordAuthPolicy"/>
        <wsoap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="hasCallPolling">
            <!-- ... -->
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="TopJtapiRemoteMethods">
        <wsdl:port name="TopJtapiRemoteMethodsHttpSoap12Endpoint" binding="ns:TopJtapiRemoteMethodsSoap12Binding">
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

My code, setting up the server:

import java.io.InputStream;
import java.util.Collections;

import javax.jws.WebService;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.ws.Endpoint;
import javax.xml.ws.Holder;

import com.topdesk.cti.topjtapi.soapserver2.HasCallPollingResponse;
import com.topdesk.cti.topjtapi.soapserver2.TopJtapiRemoteMethodsPortType;

public class EndpointTester {

    @WebService(endpointInterface = "com.topdesk.cti.topjtapi.soapserver2.TopJtapiRemoteMethodsPortType")
    private static final class MockImplementation implements TopJtapiRemoteMethodsPortType {
        @Override
        public HasCallPollingResponse hasCallPolling() {
            return null;
        }
    }

    /**
     * @see javax.xml.ws.soap.SOAPBinding#SOAP12HTTP_BINDING
     * @see https://jax-ws.dev.java.net/2.1.7/docs/soap12.html
     */
    private static final String SOAP12_BINDING_ID = "http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/";

    public static void main(String[] args) throws Exception {
        Endpoint endpoint = Endpoint.create(SOAP12_BINDING_ID, new MockImplementation());
        InputStream wsdlStream = EndpointTester.class.getResourceAsStream("/topjtapi-webapp/wsdl/TopJtapiRemoteMethods.wsdl");
        endpoint.setMetadata(Collections.<Source> singletonList(new StreamSource(wsdlStream, "http://soapserver.topjtapi.cti.topdesk.com")));
        endpoint.publish("http://localhost/services/TopJtapiRemoteMethods");

        System.in.read();
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

秉烛思 2024-09-03 10:23:41

我刚刚遇到了同样的问题,我通过将 mi 项目更新到 METRO 2.0 解决了。在 Netbeans 上,项目属性 ->导入库->地铁2.0。

在 glassfish 上只需通过命令行更新相同的库。

I just had the same problem, I solved by updating mi project to METRO 2.0. on Netbeans, Project Properties -> import Library -> MEtro 2.0.

On glassfish just update the same library by command line.

故事↓在人 2024-09-03 10:23:41

我不确定该错误,但我假设服务器不知道此名称空间: http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd

你没有写关于客户的事情。我想地铁也是。
- 具有相同版本?
- 您是否使用 wsimport 创建它?

如果不创建新客户端,请使用一些 IDE 向导来创建它,并配置安全性。如果这是人为错误,这应该有效。

I am not sure about the error, but I assume the server doesn't know about this namespace: http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd.

You don't wrote about the client. Metro also I assume.
- With same version?
- Did you use wsimport to create it?

If don't create a new client, use some IDE wizard to create it, also to configure the security. This should work if it was human error..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文