2016-09-14 35 views
0

我打电话服务在我设置OUTBOUND_MESSAGE_ATTACHMENTS以下列方式:OUTBOUND_MESSAGE_ATTACHMENTS没有到达服务器端

Map<String, DataHandler> attachmentsMap = (Map<String, DataHandler>) context.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS); 
         ByteArrayDataSource bads = new ByteArrayDataSource(file, PDF_MIME_TYPE); 

         DataHandler dh = new DataHandler(bads); 

         AttachmentPart attachmentPart = message.createAttachmentPart(); 

         attachmentPart.setContent(new ByteArrayInputStream(file), PDF_MIME_TYPE); 
         attachmentPart.setContentId(fileId); 

         String contentDisposition = "Content-Disposition: attachment; name=\"" + fileId + "\""; 
         attachmentPart.addMimeHeader("Content-Disposition", contentDisposition); 

         message.addAttachmentPart(attachmentPart); 

         attachmentsMap.put(fileId, dh); 

而在服务器端我希望找到在INBOUND_MESSAGE_ATTACHMENTS相同的信息,但似乎没有发送。

请问我在做什么错了?

+0

我看到我必须在AttachmentOutInterceptor上设置下一个属性:props.put(AttachmentOutInterceptor.WRITE_ATTACHMENTS,Boolean.TRUE)。之后,我必须将其放入JaxWsProxyFactoryBean。但问题是我应该从哪里获得JaxWsProxyFactoryBean? – Aditzu

回答

0

毕竟我自己找到了解决方案。

我不得不从Apache的CXF实现,我必须启用属性来编写附件。

JaxWsClientFactoryBean clientFactoryBean = new JaxWsClientFactoryBean(); 
      clientFactoryBean.setServiceClass(DocumentManagementForUnderwritingService.class); 
      clientFactoryBean.setAddress(serviceURL); 

      JaxWsProxyFactoryBean pfb = new JaxWsProxyFactoryBean(clientFactoryBean); 
      DocumentUploadHandler.enableSoapClientOutputAttachments(pfb); 
      DocumentManagementForUnderwritingService proxyy = (DocumentManagementForUnderwritingService) pfb.create(); 

下面我设置属性:

DocumentUploadHandler.enableSoapClientOutputAttachments(pfb); 

而且从处理程序的方法是:

public static void enableSoapClientOutputAttachments(JaxWsProxyFactoryBean pfb){ 
     Map<String,Object> props = new HashMap<String, Object>(); 
     props.put(AttachmentOutInterceptor.WRITE_ATTACHMENTS, Boolean.TRUE); 
     pfb.setProperties(props); 
     pfb.getOutInterceptors().add(new SwAOutInterceptor()); 
     pfb.getOutInterceptors().add(new AttachmentOutInterceptor()); 

    } 

我创建的代理后,我链接的处理程序:

Binding binding = proxy.getBinding(); 
     @SuppressWarnings("rawtypes") 
     final List<Handler> handlerChain = binding.getHandlerChain(); 
     handlerChain.add(documentUploadHandler); 
     binding.setHandlerChain(handlerChain); 

而处理程序的代码是目前的问题。 希望这将有助于未来的其他人。

相关问题