Spring WS:在wsdl请求中添加自定义SOAP标头

时间:2019-01-28 11:15:27

标签: java web-services spring-boot soap wsdl

我的目标是什么?

我正在尝试使用'UWLR_Leerlinggegevens_v2p2.xsd'公开soap服务,并且它还包括其他xsds: 下面显示的WSDL缺少soap:ws:input中的标头,因此在将wsdl导入SOAP UI标头部分时不会出现

View

我需要有关如何在

中添加标题部分的解决方案

出什么问题了?

这是我的代码:

<wsdl:operation name="leerkrachten">
    <soap:operation soapAction="" />
    <wsdl:input name="leerkrachten_verzoek">
        <soap:body use="literal"/>
    </wsdl:input>
    <wsdl:output name="leerkrachten_antwoord">
        <soap:body use="literal" />
    </wsdl:output>
</wsdl:operation>

还尝试了SimpleWsdl11Definition来公开直接的wsdl,而不是使用xsd

    @EnableWs
    @Configuration
    @ComponentScan(basePackageClasses = { WebServiceConfig.class })
    public class WebServiceConfig extends WsConfigurerAdapter {


    private static final String[] WS_URL_MAPPINGS = { "*.wsdl", "*.xsd"};
        @Bean
        public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
            MessageDispatcherServlet servlet = new MessageDispatcherServlet();
            servlet.setApplicationContext(applicationContext);
            servlet.setTransformWsdlLocations(true);

            return new ServletRegistrationBean(servlet, WS_URL_MAPPINGS);
        }

        @Bean(name = "leerlinggegevens")
        public DefaultWsdl11Definition defaultWsdl11Definition() {
            DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
            wsdl11Definition.setPortTypeName("leerlinggegevensPort");
            wsdl11Definition.setLocationUri("/ws");
            wsdl11Definition.setTargetNamespace("http://www.edustandaard.nl/leerresultaten/2/leerlinggegevens/");
            wsdl11Definition.setSchemaCollection(xsdSchemaCollection());
            wsdl11Definition.setRequestSuffix("_verzoek");
            wsdl11Definition.setResponseSuffix("_antwoord");
            wsdl11Definition.setFaultSuffix(":Fault");
            return wsdl11Definition;
        }


        @Bean
        public CommonsXsdSchemaCollection xsdSchemaCollection() {
            CommonsXsdSchemaCollection xsds = new CommonsXsdSchemaCollection(new Resource[] {
                    new ClassPathResource("Schemas/UWLR_Autorisatie_v2p2.xsd"),
                    new ClassPathResource("Schemas/SOAP_Envelope.xsd"),
                    new ClassPathResource("Schemas/EDEXML.types.vast.xsd"),
                    new ClassPathResource("Schemas/EDEXML.types.variabel.xsd"),
                    new ClassPathResource("Schemas/EDEXML.elementen.xsd"),
                    new ClassPathResource("Schemas/UWLR_Leerlinggegevens_v2p2.xsd")});
            xsds.setInline(true);
            return xsds;    
        }
    }

但是在导入SOAP UI时遇到问题,因为原始wsdl引用了其他xsds,如下所示

@Bean(name = "leerlinggegevens")
    public Wsdl11Definition defaultWsdl11Definition() {
        SimpleWsdl11Definition wsdl11Definition = new SimpleWsdl11Definition();
        wsdl11Definition.setWsdl(new ClassPathResource("wsdl/UWLR_Leerlinggegevens_v2p2.wsdl"));

        return wsdl11Definition;
    }

使用SimpleWsdl11Definition我不知道如何添加其他xsds

0 个答案:

没有答案