1

我的客户会给我 WSDL url,它将返回一个JPEG 图像和一些文本。

我还没有 WSDL,所以我想知道我将如何在 SOAP 消息中获取图像?

<?xml version="1.0"?> 
<soap:Envelope></soap:Envelope>
<soap:Body>
**??**
</soap:Body>

请注意 SOAP 正文中的问号。我将以哪种标签/格式获取图像?

在获得图像后,我应该使用什么数据类型在POJO中设置它?

一点解释或任何相关的教程都会很有帮助..

4

3 回答 3

1

服务响应可能包含作为 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 
    }
于 2013-09-20T08:02:48.573 回答
1

我希望这个链接能帮助你.. 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>
于 2013-09-20T07:53:28.653 回答
0

我使用 base64binary 发送文档、jpg 等。

<soap:element name="jpg" type="xs:base64Binary" minOccurs="0" maxOccurs="1"/>
于 2013-09-20T08:04:34.340 回答