Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
How to Examine the HTTP Header + Body for a POST to be sentThis example shows how to use GenerateRequestText to get the HTTP request (headers + body) that would be sent if SynchronousRequest was called with the HTTP request object. Important: The hostnames and paths in this examples are not intended to be real examples. You should replace all hostnames, paths, etc. with valid data for your own Web service. CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @sTmp0 nvarchar(4000) DECLARE @req int EXEC @hr = sp_OACreate 'Chilkat.HttpRequest', @req OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @http int EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int -- Any string unlocks the component for the 1st 30-days. EXEC sp_OAMethod @http, 'UnlockComponent', @success OUT, '30-day trial' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END -- Build an XMLHTTP request. The XML passed to UseXmlHttp is sent -- in the body of the request. EXEC sp_OAMethod @req, 'UseXmlHttp', NULL, '<test>This is the XML to be sent</test>' EXEC sp_OASetProperty @req, 'Path', '/protus/xmlwebservices/xmlsubmitter/messaging.asmx' -- Add a custom header: EXEC sp_OAMethod @req, 'AddHeader', NULL, 'SOAPAction', 'https://www.notarealdomain.com/WebServices/Messaging/2005/2/SendSingleFax' DECLARE @requestText nvarchar(4000) EXEC sp_OAMethod @req, 'GenerateRequestText', @requestText OUT PRINT @requestText PRINT '----------------------' -- Send the HTTP POST and get the response. Note: This is a blocking call. -- The method does not return until the full HTTP response is received. DECLARE @resp int EXEC sp_OAMethod @http, 'SynchronousRequest', @resp OUT, 'www.notarealdomain.com', 443, 1, @req IF @resp Is NULL BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 END ELSE BEGIN -- Display the body of the response. EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT PRINT @sTmp0 END END GO |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.