从MIME响应中提取JPG?

时间:2019-04-25 07:03:24

标签: vb6 jpeg mime msxml

我正在使用远程Web服务,但是无法提取ResponseBody中包含的jpg文件。我确实保存了文件,但是如何删除Mime标头等,以便查看图像?

这是我的代码:

Sub GetImg(ByVal strUrl As String, ByVal XmlBody As String)
    Dim objDom As Object
    Dim objXmlHttp As Object
    Dim strRet As String
    Dim aRes() As Byte, fn As Integer


' Create objects to DOMDocument and XMLHTTP
    Set objDom = CreateObject("MSXML2.DOMDocument")
    Set objXmlHttp = CreateObject("MSXML2.XMLHTTP")

' Load XML
    objDom.async = False
    objDom.loadXML XmlBody

' Open the webservice
    objXmlHttp.Open "POST", strUrl, False

' Create headings
    objXmlHttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
    objXmlHttp.setRequestHeader "Accept", "image/jpeg"
    objXmlHttp.setRequestHeader "Content-Length", Len(XmlBody)

' Send XML command
    objXmlHttp.send objDom.xml

' Get all response text from webservice
    strRet = objXmlHttp.responseText

' Get image
    aRes = objXmlHttp.responseBody
    fn = FreeFile
    Open "a.jpg" For Binary As fn
    Put fn, , aRes
    Close fn

' Close objects
    Set objXmlHttp = Nothing
    Set objDom = Nothing 

End Sub

我得到以下ResponseText。我似乎内容类型是应用程序/二进制,也许这就是为什么我以这种方式获得图像的原因?

--MIME_boundaryB0R9532143182121
Content-Type: text/xml
Content-ID: <http://www.borland.com/rootpart.xml>
Content-Location: http://www.borland.com/rootpart.xml
Content-Length: 528
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<NS1:Get_TestImageResponse xmlns:NS1="urn:LabLinkIntf-ILabLink">
<return href="cid:1D9766A6-B088-4408-B023-283F7AB6EEB1"/>
</NS1:Get_TestImageResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
--MIME_boundaryB0R9532143182121
Content-ID: <1D9766A6-B088-4408-B023-283F7AB6EEB1>
Content-Length: 1035666
Content-Type: application/binary

BM??

但是,通过使用在线肥皂客户端,我得到了附件的答案(如果单击红色名称,我确实会得到jpg !!!)。

OnLine SOAP Client Response

他们这样做吗?

0 个答案:

没有答案