无法处理mustUnderstand标头:{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}安全性.返回故障 [英] Could not handle mustUnderstand headers: {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security. Returning fault

查看:504
本文介绍了无法处理mustUnderstand标头:{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}安全性.返回故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过了如下链接: SOAPFaultException"必须了解标题(oasis-200401-wss-wssecurity-secext-1.0.xsd)被理解为"",但仍在挣扎.

I went through links like: SOAPFaultException "MustUnderstand headers (oasis-200401-wss-wssecurity-secext-1.0.xsd) are not understood", but still struggling.

我正在使用Spring Boot v2.2.2..RELEASE and SOAP项目.

我正在将两个不同的WSDL文件加载到我的项目中.一个URL生成为http://localhost:8080/employee/employee-soap,它工作正常.但是http://localhost:8080/student/student-soap这给出了以下错误.

I am loading two different WSDL file into my project. One URL Generates to http://localhost:8080/employee/employee-soap which works fine. But http://localhost:8080/student/student-soap this gives below error.

2020-02-17 15:31:00.241警告20236 --- [nio-8080-exec-5] oswsoap.server.SoapMessageDispatcher:无法处理mustUnderstand标头:{

2020-02-17 15:31:00.241 WARN 20236 --- [nio-8080-exec-5] o.s.w.soap.server.SoapMessageDispatcher : Could not handle mustUnderstand headers: {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security. Returning fault

JavaCode:

@EnableWs
@Configuration
public class AppConfig extends WsConfigurerAdapter {

    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Bean
    public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
        MessageDispatcherServlet servlet = new MessageDispatcherServlet();
        servlet.setApplicationContext(applicationContext);
        servlet.setTransformWsdlLocations(true);
        return new ServletRegistrationBean(servlet, "/*");
    }

    @Bean
    public SaajSoapMessageFactory messageFactory() {
        SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory();
        messageFactory.setSoapVersion(SoapVersion.SOAP_11);
        messageFactory.afterPropertiesSet();
        return messageFactory;
    }

    @Bean("empXSD")
    public XsdSchema organizationSchema() {
        return new SimpleXsdSchema(new ClassPathResource("/xsd/employee.xsd"));
    }


    @Bean(name = "employee")
    public DefaultWsdl11Definition defaultWsdl11Definition(@Qualifier("empXSD") XsdSchema schema) {
        DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
        wsdl11Definition.setPortTypeName("employee");
        wsdl11Definition.setLocationUri("employee/employee-soap");
        wsdl11Definition.setTargetNamespace("urn:example.com:dms:wsdls:employee");
        wsdl11Definition.setSchema(schema);
        wsdl11Definition.setCreateSoap11Binding(true);
        return wsdl11Definition;
    }

    @Bean
    @Qualifier(value="stuXSD")
    public XsdSchema stuSchema() {
        return new SimpleXsdSchema(new ClassPathResource("/xsd/student.xsd"));
    }

    @Bean(name = "student")
    public DefaultWsdl11Definition geographyWsdl11Definition(@Qualifier("stuXSD") XsdSchema schema) {
        DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
        wsdl11Definition.setPortTypeName("student");
        wsdl11Definition.setLocationUri("student-soap");
        wsdl11Definition.setTargetNamespace("urn:example.com:dms:wsdls:student");
        wsdl11Definition.setSchema(schema);
        wsdl11Definition.setCreateSoap11Binding(true);
        return wsdl11Definition;
    }


    @Override
    public void addInterceptors(List<EndpointInterceptor> interceptors) {
        interceptors.add(new Interceptor(endpoints, req));
    }
}

代码:

@Configuration
public class SimpleMustUnderstandEndpointInterceptor implements SoapEndpointInterceptor{
    private final String SAMPLE_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";

    @Override
    public boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception {
        return true;
    }

    @Override
    public boolean handleResponse(MessageContext messageContext, Object endpoint) throws Exception {
        return true;
    }

    @Override
    public boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception {
        return true;
    }

    @Override
    public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception {

    }

    @Override
    public boolean understands(SoapHeaderElement header) {
        if(header.getName().getNamespaceURI().equalsIgnoreCase(SAMPLE_NS)) {
            return true;
        }
        return false;
    }

}

每次观察,看起来甚至是这个SoapEndpointInterceptor都没有调用,只是它给了错误.

Per observation, looks like even this SoapEndpointInterceptor is not calling, before to that only its giving error.

在调用SOAP端点期间,标题信息在下面,并且如上所述,它给出了Fault.有指针吗?

During calling SOAP endpoint, below header information is going and its giving Fault as I mentioned above. Any pointers ?

<soapenv:Header><wsse:Security soapenv:mustUnderstand="1" 
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity- 
secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401- 
wss-wssecurity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken- 
518482F2CDC2F635FF158202815227129"><wsse:Username>aispoc_usr1</wsse:Username> 
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss- 
username-token-profile-1.0#PasswordText">aispoc_usr1</wsse:Password><wsse:Nonce 
EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap- 
message-security-1.0#Base64Binary">/fdGCEilz/dkVeZE05b7LQ==</wsse:Nonce> 

2020-02-18T12:15:52.271Z

2020-02-18T12:15:52.271Z

推荐答案

我能够通过 https://memorynotfound.com/spring-ws-username-password-authentication-wss4j/.

我只是在bean下面使用它,并且开始工作正常.

I simply used below bean and its started working fine.

@Bean
public Wss4jSecurityInterceptor securityInterceptor() {
  Wss4jSecurityInterceptor security = new Wss4jSecurityInterceptor();
  security.setSecurementActions("NoSecurity");
  security.setSecurementPasswordType(WSConstants.PW_TEXT);
  return security;
}

这篇关于无法处理mustUnderstand标头:{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}安全性.返回故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆