[英]How to Get Image from a SOAP Web Service
我的客戶將給我WSDL URL,它將返回JPEG圖像和一些文本。
我還沒有WSDL,所以我想知道我將如何在SOAP消息中獲取圖像?
<?xml version="1.0"?>
<soap:Envelope></soap:Envelope>
<soap:Body>
**??**
</soap:Body>
注意SOAP正文中的問號 。 我將以哪種標簽/格式獲取圖像?
在獲取圖像后,我應該使用哪種Java數據類型在POJO中進行設置?
一點解釋或任何相關的Tutorail都會很有幫助。
我希望此鏈接對您有幫助。.http ://www.ibm.com/developerworks/xml/library/x-tippass/
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ps:retrieve
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ps="http://psol.com/2004/ws/retrieve">
<address xsi:type="xsd:base64Binary">d3d3Lm1hcmNoYWwuY29t</address>
</ps:retrieve>
</soapenv:Body>
</soapenv:Envelope>
服務響應可能包含base64圖片或信封外部的附件。 解碼base64的示例:
public static BufferedImage decodeToImage(String imageString) {
BufferedImage image = null;
byte[] imageByte;
try {
BASE64Decoder decoder = new BASE64Decoder();
imageByte = decoder.decodeBuffer(imageString);
ByteArrayInputStream bis = new ByteArrayInputStream(imageByte);
image = ImageIO.read(bis);
bis.close();
} catch (Exception e) {
e.printStackTrace();
}
return image;
}
JAVA已經有一個用於處理帶有附件的SOAP的API。
SOAPMessage response = connection.call(requestMessage, serviceURL);
Iterator attachmentsIterator = response.getAttachments();
while (attachmentsIterator.hasNext()) {
AttachmentPart attachment = (AttachmentPart) attachmentsIterator.next();
//do something with attachment
}
我使用base64binary發送文檔,jpg等。
<soap:element name="jpg" type="xs:base64Binary" minOccurs="0" maxOccurs="1"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.