2016-09-14 8 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を実装しなければならず、添付ファイルを書き込むためにプロパティを有効にする必要があります。

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); 
私はプロパティを設定する下

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

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

ハンドラのコードは次のとおりです。問題の中に存在する。 これは将来他の人に役立つことを願っています。

関連する問題