我写了一个调用soap服务的客户端,但它发送的请求不是我所期望的。
下面是我代码:
public MessageResponse traGiayToHoSo (MessageRequest request) {
Message message = new Message();
ThongTinXacThuc thongTinXacThuc = new ThongTinXacThuc();
ThongTinHoSo thongTinHoSo = new ThongTinHoSo();
FileDinhKem fileDinhKem = new FileDinhKem();
fileDinhKem.setFileName("FvutqPDmkkC4cWjRsample.docx");
fileDinhKem.setExtension("docx");
fileDinhKem.setByteFile("UEsDBBQABgAIAAAAIQACD0AObDN+AHb0BC9/49I0+Ucq8qbBPyFxyfgjbnRFHdZGrU5P8rUqfPjZtgexsaAAAAAAAAAAAAAzkMAAGN1c3RvbVhtbC9fcmVscy9pdGVtMy54bWwucmVsc1BLBQYAAAAAFgAWALkFAADVRQAAAAA=");
fileDinhKem.setSize("19364");
thongTinXacThuc.setUserName("igate_eoffice");
thongTinXacThuc.setPassWord("igate_eoffice");
thongTinHoSo.setFileDinhKems(new FileDinhKem[]{fileDinhKem});
thongTinHoSo.setMaHoSo("587205");
message.setThongTinHoSo(thongTinHoSo);
message.setThongTinXacThuc(thongTinXacThuc);
request.setMessage(message);
MessageResponse response = (MessageResponse) getWebServiceTemplate().marshalSendAndReceive(request);
System.out.println(response.toString());
return response;
}
使用上面的代码,我发送一个请求如下:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<messageRequest>
<message>
<thongTinHoSo>
<fileDinhKems>
<byteFile>UEsDBBQABgAIAAAAIQACD0AObDN+AHb0BC9/49I0+Ucq8qbBPyFxyfgjbnRFHdZGrU5P8rUqfPjZtgexsaAAAAAAAAAAAAAzkMAAGN1c3RvbVhtbC9fcmVscy9pdGVtMy54bWwucmVsc1BLBQYAAAAAFgAWALkFAADVRQAAAAA=</byteFile>
<extension>docx</extension>
<fileName>FvutqPDmkkC4cWjRsample.docx</fileName>
<size>19364</size>
</fileDinhKems>
<maHoSo>587205</maHoSo>
</thongTinHoSo>
<thongTinXacThuc>
<passWord>igate_eoffice</passWord>
<userName>igate_eoffice</userName>
</thongTinXacThuc>
</message>
</messageRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我想将xmlns:tns=”http://schemas.xmlsoap.org/soap/encoding/“添加到SOAP-ENV:Envelope标记中,我应该怎么做?
1条答案
按热度按时间atmip9wb1#
尝试使用以下方法:
你可以修改你的代码来添加xmlns:tns命名空间声明,就像我发送的那样。