on 2016 Feb 12 3:32 AM
When using a web client function, is there a way to receive the HTTP header details of the HTTP response?
The "WebClientLogging" facility does log them, such as
Transfer-Encoding: chunked Content-Type: text/xml; charset=utf-8 Server: Microsoft-IIS/8.5 X-AspNet-Version: 4.0.30319 ...
However, the web client funtion will only get the response's body.
For a web service, I would use the HTTP_HEADER() function family to get these values from the HTTP request and the HTTP_RESPONSE_HEADER() functions to get this from the created response. But these don't seem to apply for a web client function (and even if they do, I would not know how/where to call them...).
(In my case I would be particularly interested in the Content-Type header of a SOAP response.)
Request clarification before answering.
After some more reading and some more testing based on Mark's response from that FAQ, I guess the answer is:
No, you can't with a web client function. You do need a web client procedure.
Furthermore, the web client procedure cannot use type SOAP:DOC, as that still only returns the SOAP body (and SOAP headers).
So I'll guess when trying to get the HTTP response headers of a SOAP request, I have to use a web client procedure of type HTTP:POST (and therefore have to build the SOAP envelope myself), such as
create or replace procedure WSP_StartRequestRaw(XmlPayload long nvarchar) result (attribute long varchar, value long varchar) url 'http://...' type 'HTTP:POST:text/xml' header 'SOAPAction:"urn:StartRequest"' set 'HTTP(VERSION=1.1;CHUNK=OFF)';
Then I can access the desired headers as following:
select * from dbo.WSP_StartRequestRaw(xmlSoapEnvelope)
where attribute = 'Content-Type';
Sigh.
I should have better read the docs more carefully - it's documented here, of course, I should add:):
Variables accessed from result sets
Web service client calls can be made with stored functions or procedures. If made from a function, the return type must be of a character data type, such as CHAR, VARCHAR, or LONG VARCHAR. The body of the HTTP response is the returned value. No header information is included. Additional information about the request, including the HTTP status information, is returned by procedures. So, procedures are preferred when access to additional information is desired.SOAP procedures
The response from a SOAP function is an XML document that contains the SOAP response.
(The last sentence implicitly telling that SOAP procedures do not return the full HTTP response.)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
52 | |
8 | |
5 | |
5 | |
5 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.