-->

春天开机多SOAP Web服务客户端不读附件(Spring boot multipart SOAP

2019-11-05 08:12发布

我正在开发一个春天启动SOAP客户端的Webservice它调用一个SOAP服务和SOAP服务返回的响应正文附件。 附件将MTOM附件。

我的代码,我可以能够读取SOAP的Web服务响应的身体,但没能得到附件内容。

我使用Spring 1.5.2引导和我的配置看起来像下面。

@Bean(name="myMarshaller")
    public Jaxb2Marshaller myMarshaller() {
        Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
        marshaller.setPackagesToScan(new String[] {"com.mypack.header",
                "com.soapservice.schema",               
                "com.soapservice.exception"});
        marshaller.setMtomEnabled(true);
        return marshaller;
    }

@Bean(name = "myAppJaxbContext")
    public JAXBContext myAppJaxbContext() throws XmlMappingException
    { 
        return myMarshaller().getJaxbContext();

    }

@Bean(name = "messageFactory")
    public SaajSoapMessageFactory messageFactory() 
    {
        return new SaajSoapMessageFactory();
    }

@Bean(name = "myAppWSTemplate")
    public WebServiceTemplate myAppWSTemplate() throws SOAPException
    {
        WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
        webServiceTemplate.setMessageFactory(messageFactory());
        webServiceTemplate.setCheckConnectionForFault(false);
        webServiceTemplate.setCheckConnectionForError(false);
        webServiceTemplate.setUnmarshaller(myMarshaller());
        webServiceTemplate.setMarshaller(myMarshaller());

        return webServiceTemplate;
    }

SOAP服务响应

<mySoapResponse xmlns:e="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:dime="http://schemas.xmlsoap.org/ws/2002/04/reference/" xmlns:fn40="http://www.filenet.com/soapservice/schema"  xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema">
         <FiledetailResponse retrievalName="myapp.pdf" totalSize="177712">
            <Content>
               <Binary>
                  <xop:Include href="cid:v1-1234abc@mtom.p128ae.myapp.com"/>
               </Binary>
            </Content>
         </FiledetailResponse>
      </mySoapResponse>

与上述反应体我将得到的附接作为MIME类型。 但是,当尝试解组此响应体content.getBinary()将总是为空。 但是,当我打印的SOAP响应,我可以见附件二。

我失去了我的配置的东西。 是否有春天启动web服务客户端的多SOAP任何例子。

文章来源: Spring boot multipart SOAP web service client not reading attachment