我正在尝试从Apache CXF客户端调用附件SOAP Web服务,但无法调用。
以下是我的示例
public class Test1 {
public static void doInvoke() throws Exception {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient("http://localhost:6060/ForAttachments", classLoader);
ClientImpl clientImpl = (ClientImpl) client;
Endpoint endpoint = clientImpl.getEndpoint();
endpoint.put("mtom-enabled", "true");
BindingOperationInfo bindingOperationInfo = client.getEndpoint().getBinding().getBindingInfo()
.getOperation(new QName(endpoint.getService().getName().getNamespaceURI(), "Attachments"));
List<Attachment> attachments = new ArrayList<Attachment>();
Map<String, List<String>> headers = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
headers.put("Content-Type", Arrays.asList("application/pdf"));
Attachment attach = AttachmentUtil
.createAttachment(new FileDataSource(new File("D:\\images\\test.pdf")).getInputStream(), headers);
attachments.add(attach);
Object[] result = client.invoke(bindingOperationInfo, attachments);
}
}
我已经在Fidler中捕获了请求
此处缺少二进制数据.........
Content-Length: 567
Content-Type: multipart/related;
type="application/xop+xml";
boundary="uuid:09b6bee3-59f3-4662-a3ac-5e0b01d2f76f";
start="<root.message@cxf.apache.org>"; start-info="text/xml"
请您帮我解决这个问题