Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 如何在Spring BOOT WS中返回MTOM_Spring Boot_Soap_Spring Ws_Mtom - Fatal编程技术网

Spring boot 如何在Spring BOOT WS中返回MTOM

Spring boot 如何在Spring BOOT WS中返回MTOM,spring-boot,soap,spring-ws,mtom,Spring Boot,Soap,Spring Ws,Mtom,我的Spring Boot Soap服务器有问题,我使用Spring WS,我必须在附件中返回文件,我将Datahandler返回到Jaxb创建的listtype,但我在Soap ui的响应中看到了附件0,并在base64中返回了文件。 我不知道怎么做。 你能帮助我吗。 非常感谢 我的配置Bean是: @Bean public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationCo

我的Spring Boot Soap服务器有问题,我使用Spring WS,我必须在附件中返回文件,我将Datahandler返回到Jaxb创建的listtype,但我在Soap ui的响应中看到了附件0,并在base64中返回了文件。 我不知道怎么做。 你能帮助我吗。 非常感谢

我的配置Bean是:

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

    @Bean(name = "students")
    public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) {
        DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
        wsdl11Definition.setPortTypeName("StudentPort");
        wsdl11Definition.setLocationUri("/ws/services/test");
        wsdl11Definition.setTargetNamespace("http://www.example.org/demo/");
        wsdl11Definition.setSchema(countriesSchema);
        Properties props = new Properties();
        props.put("getDemo", "http://www.example.org/demo/getDemoRequest");
        wsdl11Definition.setSoapActions(props);

        return wsdl11Definition;
    }

    @Bean
    public XsdSchema countriesSchema() {
        return new SimpleXsdSchema(new ClassPathResource("/it/xsd/demo.xsd"));
    }
我的端点只有以下注释:

@PayloadRoot(namespace = NAMESPACE_URI, localPart = "getDemoRequest")
    @ResponsePayload
在我的demo.xsd中,我将文件类型设置为

<element name="fileType" type="base64Binary" maxOccurs="unbounded" xmime:expectedContentTypes="application/octet-stream">

我现在还并没有xml配置,若在完美的Spring引导风格中并没有必要,我不想使用任何xml

非常感谢

向上: 我的代码尝试启用MTOM

  import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.oxm.jaxb.Jaxb2Marshaller;
    import org.springframework.ws.config.annotation.WsConfigurerAdapter;
    import org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor;
    import org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver;

    import java.util.List;

    @Configuration
public class MTOMEnable extends WsConfigurerAdapter {
    @Override
    public void addArgumentResolvers(List<MethodArgumentResolver> argumentResolvers) {
        argumentResolvers.add(methodProcessor());
    }

    @Bean
    public Jaxb2Marshaller marshaller() {
        Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
        marshaller.setClassesToBeBound(GetStudentsResponse.class);
        marshaller.setMtomEnabled(true);
        return marshaller;
    }

    @Bean
    public MarshallingPayloadMethodProcessor methodProcessor() {
        return new MarshallingPayloadMethodProcessor(marshaller());
    }
}
import org.springframework.context.annotation.Bean;
导入org.springframework.context.annotation.Configuration;
导入org.springframework.oxm.jaxb.Jaxb2Marshaller;
导入org.springframework.ws.config.annotation.WsConfigurerAdapter;
导入org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor;
导入org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver;
导入java.util.List;
@配置
公共类MTOMEnable扩展了WsConfigurerAdapter{
@凌驾
public void addArgumentResolver(列出ArgumentResolver){
ArgumentResolver.add(methodProcessor());
}
@豆子
公共Jaxb2Marshaller-marshaller(){
Jaxb2Marshaller-marshaller=新的Jaxb2Marshaller();
setClassesToBeBound(GetStudentsResponse.class);
marshaller.setMtomEnabled(true);
返回编组员;
}
@豆子
公共编组PayloadMethodProcessor方法处理器(){
返回新的MarshallingPayloadMethodProcessor(marshaller());
}
}
POM

<dependencies>
        <!-- SOAP DEPENDENCIES-->
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <version>2.3.2</version>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>javax.xml.ws</groupId>
            <artifactId>jaxws-api</artifactId>
            <version>2.3.1</version>
        </dependency>

        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-ri</artifactId>
            <version>2.3.2</version>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>com.sun.org.apache.xml.internal</groupId>
            <artifactId>resolver</artifactId>
            <version>20050927</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>2.2.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>wsdl4j</groupId>
            <artifactId>wsdl4j</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.9</version>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.13</version>
        </dependency>
        <!--<dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>6.2.0.jre8</version>
            <scope>runtime</scope>
        </dependency>-->
        <dependency>
            <groupId>net.sourceforge.jtds</groupId>
            <artifactId>jtds</artifactId>
            <version>1.3.1</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.4.0-b180830.0359</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/javax.activation/activation -->
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1.1</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-runtime -->
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>2.4.0-b180830.0438</version>
        </dependency>

        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.4</version> <!-- makesure you put a correct version here -->
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

com.sun.xml.ws
jaxws-rt
2.3.2
聚甲醛
javax.xml.ws
JAXWSAPI
2.3.1
com.sun.xml.ws
jaxws-ri
2.3.2
聚甲醛
com.sun.org.apache.xml.internal
分解器
20050927
org.springframework.boot
SpringBootStarterWeb服务
org.springframework.boot
spring引导启动器数据jpa
2.2.2.1发布
wsdl4j
wsdl4j
org.springframework.boot
弹簧起动试验
测试
org.apache.commons
commons-lang3
3.9
通用编解码器
通用编解码器
1.13
net.sourceforge.jtds
jtds
1.3.1
javax.xml.bind
jaxb api
2.4.0-b180830.0359
javax.activation
激活
1.1.1
org.glassfish.jaxb
jaxb运行时
2.4.0-b180830.0438
文件上传
文件上传
1.4
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧启动机tomcat
org.springframework.boot
弹簧启动机tomcat
假如

评论不用于扩展讨论;这段对话已经结束。嗨@Toriga,你成功地让它工作了吗?