问题描述
我正在尝试使用OLE Automation存储过程从sql Server调用SOAP Web服务,但是响应却很麻烦,它是content-encoding gzip。
当测试使用SOAP UI的方法时,它就像是一种魅力。
Soap UI shows response like xml. Http log shows response is gzip encoded
当我从sql Server拨打电话时,收到类似这样的意外响应
状态返回正常200。
GetAllResponseHeaders
不包含'content-encoding:gzip',Soap UI包含!
我包括了SOAP UI上显示的所有请求标头。
DECLARE
@URI varchar(2000) = 'http://foo/foo.wsdl',@methodName varchar(50) = 'post',@requestBody varchar(8000) = '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:CCTwebservices"><soapenv:Header/><soapenv:Body><urn:recepcionLiberacionTatc soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><user xsi:type="xsd:string">foo</user><password xsi:type="xsd:string">foo</password><dataIn xsi:type="xsd:string"><![CDATA[foo]]></dataIn></urn:recepcionLiberacionTatc></soapenv:Body></soapenv:Envelope>',@SoapAction varchar(255) = 'urn:CCTwebservices#recepcionLiberacionTatc',@responseText varchar(8000);
DECLARE @objectID int
DECLARE @hResult int
DECLARE @source varchar(255),@desc varchar(255)
--create object
EXEC @hResult = sp_OACreate 'MSXML2.ServerXMLHTTP',@objectID OUT
-- open the destination URI with Specified method
EXEC @hResult = sp_OAMethod @objectID,'open',null,@methodName,@URI,'false',null
-- set request headers
EXEC @hResult = sp_OAMethod @objectID,'setRequestHeader','Content-Type','text/xml;charset=UTF-8'
EXEC @hResult = sp_OAMethod @objectID,'Accept-Encoding','gzip,deflate'
EXEC @hResult = sp_OAMethod @objectID,'Host','ws.foo`enter code here`.cl'
EXEC @hResult = sp_OAMethod @objectID,'Connection','Keep-Alive'
EXEC @hResult = sp_OAMethod @objectID,'SOAPAction',@SoapAction
declare @len int
set @len = len(@requestBody)
EXEC @hResult = sp_OAMethod @objectID,'Content-Length',@len
-- send the request
EXEC @hResult = sp_OAMethod @objectID,'send',@requestBody
EXEC @hResult = sp_OAMethod @objectID,'getResponseHeader','content-encoding' -- Return null
EXEC @hResult = sp_OAMethod @objectID,'GetAllResponseHeaders' -- Response doesn't incluye 'content-encoding: gzip',Soap UI does!.
exec sp_OAGetProperty @objectID,'StatusText'
exec sp_OAGetProperty @objectID,'Status'
exec sp_OAGetProperty @objectID,'responseText' -- return the xml show previosly
exec sp_OADestroy @objectID
对这项工作有帮助吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)