2016-09-14 2 views
0

J'appelle un service dans lequel je régler les OUTBOUND_MESSAGE_ATTACHMENTS de la manière suivante:OUTBOUND_MESSAGE_ATTACHMENTS ne pas arriver à côté serveur

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); 

Et sur le côté serveur, je pense trouver les mêmes informations dans les INBOUND_MESSAGE_ATTACHMENTS mais semble que rien n'est envoyé.

Pouvez-vous ce que je fais mal?

+0

je vis que je dois mettre en quelque sorte sur AttachmentOutInterceptor la prochaine propriété: props.put (AttachmentOutInterceptor.WRITE_ATTACHMENTS, Boolean.TRUE). Et après cela, je dois mettre dans JaxWsProxyFactoryBean. Mais la question est d'où devrais-je obtenir JaxWsProxyFactoryBean? – Aditzu

Répondre

0

Après tout ce que je trouve la solution par moi-même.

je vous avais mise en œuvre CXF d'Apache et je dois activer la propriété pour écrire la pièce jointe.

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

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

Ci-dessous je mets la propriété:

DocumentUploadHandler.enableSoapClientOutputAttachments(pfb); 

Et la méthode du gestionnaire est:

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()); 

    } 

Après avoir créé le proxy, je chaînés le gestionnaire:

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

Et le code du gestionnaire est présent dans la question. J'espère que cela aidera quelqu'un d'autre dans le futur.