none
MSXML6.dll method"SEND" don't work in Windows Server 2012 and SQL 2008R2 RRS feed

  • Question

  • Hi all,

    I have a SP to send a WebService data

    It works fine on Windows 2008R2 server and also on Windows Server 2003.

    moving it on Windows Server 2012 with SQL 2008R2 express (32bit) or SQL 2012 express (32bit), it doesn't work anymore.

    Below the SP.

    -- =============================================
    -- Author:	Giancarlo MADA Service 2008
    -- Create date: 09/09/2008
    -- Description:	Web Service Interface
    -- =============================================
    CREATE PROCEDURE [dbo].[spmd_HTTPRequest]
          @URI varchar(2000) = '',     
          @methodName varchar(50) = '', -- POST, GET
          @requestBody varchar(8000) = '', -- XML Document envelope
          @SoapAction varchar(255),
          @UserName nvarchar(100), -- Domain\UserName or UserName
          @Password nvarchar(100),
          @responseText varchar(8000) output
    as
    SET NOCOUNT ON
    IF    @methodName = ''
    BEGIN
          select FailPoint = 'Method Name must be set'
          return
    END
    set   @responseText = 'FAILED'
    DECLARE @objectID int
    DECLARE @hResult int
    DECLARE @source varchar(255), @desc varchar(255)
    EXEC @hResult = sp_OACreate 'MSXML2.ServerXMLHTTP.6.0', @objectID OUT
    IF @hResult <> 0
    BEGIN
          EXEC sp_OAGetErrorInfo @objectID, @source OUT, @desc OUT
          SELECT      hResult = convert(varbinary(4), @hResult),
                      source = @source,
                      description = @desc,
                      FailPoint = 'Create failed',
                      MedthodName = @methodName
          goto destroy
          return
    END
    -- open the destination URI with Specified method
    EXEC @hResult = sp_OAMethod @objectID, 'open', null, @methodName, @URI, 'false', @UserName, @Password
    IF @hResult <> 0
    BEGIN
          EXEC sp_OAGetErrorInfo @objectID, @source OUT, @desc OUT
          SELECT      hResult = convert(varbinary(4), @hResult),
                source = @source,
                description = @desc,
                FailPoint = 'Open failed',
                MedthodName = @methodName
          goto destroy
          return
    END
    -- set request headers
    EXEC @hResult = sp_OAMethod @objectID, 'setRequestHeader', null, 'Content-Type', 'text/xml;charset=UTF-8'
    IF @hResult <> 0
    BEGIN
          EXEC sp_OAGetErrorInfo @objectID, @source OUT, @desc OUT
          SELECT      hResult = convert(varbinary(4), @hResult),
                source = @source,
                description = @desc,
                FailPoint = 'SetRequestHeader failed',
                MedthodName = @methodName
          goto destroy
          return
    END
    -- set soap action
    EXEC @hResult = sp_OAMethod @objectID, 'setRequestHeader', null, 'SOAPAction', @SoapAction
    IF @hResult <> 0
    BEGIN
          EXEC sp_OAGetErrorInfo @objectID, @source OUT, @desc OUT
          SELECT      hResult = convert(varbinary(4), @hResult),
                source = @source,
                description = @desc,
                FailPoint = 'SetRequestHeader failed',
                MedthodName = @methodName
          goto destroy
          return
    END
    declare @len int
    set @len = len(@requestBody)
    EXEC @hResult = sp_OAMethod @objectID, 'setRequestHeader', null, 'Content-Length', @len
    IF @hResult <> 0
    BEGIN
          EXEC sp_OAGetErrorInfo @objectID, @source OUT, @desc OUT
          SELECT      hResult = convert(varbinary(4), @hResult),
                source = @source,
                description = @desc,
                FailPoint = 'SetRequestHeader failed',
                MedthodName = @methodName
          goto destroy
          return
    END
    
    -- send the request
    EXEC @hresult = sp_OAMethod @objectID, 'send', NULL, @requestBody 
    IF    @hResult <> 0
    BEGIN
          EXEC sp_OAGetErrorInfo @objectID, @source OUT, @desc OUT
          SELECT      hResult = convert(varbinary(4), @hResult),
                source = @source,
                description = @desc,
                FailPoint = 'Send failed',
                MedthodName = @methodName
          goto destroy
          return
    END
    declare @statusText varchar(1000), @status varchar(1000)
    -- Get status text
    exec sp_OAGetProperty @objectID, 'StatusText', @statusText out
    exec sp_OAGetProperty @objectID, 'Status', @status out
    select @status, @statusText, @methodName
    -- Get response text
    exec sp_OAGetProperty @objectID, 'responseText', @responseText out
    IF @hResult <> 0
    BEGIN
          EXEC sp_OAGetErrorInfo @objectID, @source OUT, @desc OUT
          SELECT      hResult = convert(varbinary(4), @hResult),
                source = @source,
                description = @desc,
                FailPoint = 'ResponseText failed',
                MedthodName = @methodName
          goto destroy
          return
    END
    destroy:
          exec sp_OADestroy @objectID
    SET NOCOUNT OFF
     
    The underlined portion is the one that gives error, reported below.

    "Msxml6.dll 0x80070057 The parameter is incorrect. Send failed POST"

    Previously the SP used MSXML3.dll and also with that it gives the same problem.

    I can't understand what the wrong parameter is.

    Even because, as mentioned at the beginning, everything works fine on windows server 2008R2 and Windows Server 2003

    Some ideas?

    Sunday, February 24, 2013 10:10 AM

Answers

All replies

  • Consider filing a connect.
    Sunday, February 24, 2013 2:56 PM
    Answerer
  • Hi wBob,

    Sorry, what do you mean for "fill a connect"?

    Thank.

    Sunday, February 24, 2013 5:37 PM
  • connect is where you file bugs.  Follow the link, register, file your bug:

    https://connect.microsoft.com/

    Sunday, February 24, 2013 6:04 PM
    Answerer
  • Hi wBob,

    I have posted now in connect.microsoft.com this problem after your suggestion.
    Thank you.

    Monday, February 25, 2013 7:48 AM
  • Has anybody got a solution to this problem?. I'm facing the same problem after moving my data base from SQL Server 2008 R2 to SQL Server 2012.
    Wednesday, March 5, 2014 2:30 AM
  • Hello, 
    We have built a dll via CLR on the database. 
    Below is the code.

    If you want to send the file SOAP.dll. Give me an e-mail ..


    USE Mydatabase

    GO /****** Object: SqlAssembly [SOAP] Script Date: 03/05/2014 12:59:14 ******/ CREATE ASSEMBLY [SOAP] AUTHORIZATION [dbo] FROM MyPath\SOAP.dll WITH PERMISSION_SET = EXTERNAL_ACCESS GO

    USE Mydatabase
    GO
    
    /****** Object:  StoredProcedure [dbo].[spmd_HTTPRequest3]    Script Date: 03/05/2014 12:53:32 ******/
    CREATE PROCEDURE [dbo].[spmd_HTTPRequest3]
    	@URI [nvarchar](4000),
    	@methodName [nvarchar](4000),
    	@requestBody [nvarchar](4000),
    	@SoapAction [nvarchar](4000),
    	@UserName [nvarchar](4000),
    	@Password [nvarchar](4000),
    	@responseText [nvarchar](4000) OUTPUT
    	
    WITH EXECUTE AS CALLER
    AS
    EXTERNAL NAME [SOAP].[StoredProcedures].[spmd_HTTPRequest3]
    GO
    

    Now call the new SP called spmd_HTTPRequest3

    By..

    Wednesday, March 5, 2014 12:17 PM
  • Hello Giancarlo.

    I'm more then interested in the SOAP.DLL.
    Im currently running into a issue where the response exceeds the 8000 characters. I receive a PDF in Base64 coded string.

    My adres is martijn.bergevoet.work@gmail.com

    thanks


    Monday, April 7, 2014 10:48 AM
  • Hello,

    I want this dll (SOAP.DLL) too, if it's possible. 

    Thanks in advance,

    Cristy

    My email adress is cristy@asw.ro
    Tuesday, April 29, 2014 10:04 AM
  • Giancarlo,

    I solved this issue in an unconventional way but it's MS's fault for creating this problem and breaking something that used to work.

    SOLUTION:

    I copied  C:\Windows\System32\msxml3.dll from a Server 2008 to the same dir on a server 2012. Problem on 2012 server solved, sending with POST and GET working fine.

    • Proposed as answer by NetSpace-com Sunday, June 1, 2014 6:09 PM
    Sunday, June 1, 2014 7:05 AM
  • please send me your soap.dll, many thanks
    Tuesday, June 17, 2014 10:46 PM
  • Hi Giancarlo,

    I have to communicate with soap instead of restXML.

    I'm interested by your soap.dll, if you please.

    My address is alain@de-angelis.fr

    Thanks in advance

    Alain

    Thursday, July 28, 2016 8:59 AM
  • Hi alain,

    via email i send you a zip file with soap.ddl in compiled with .net framework 2.0, 3.0 and 3.5

    by

    Monday, August 1, 2016 9:45 AM
  • I stumbled upon this nasty issue for an entire weekend. I personally found horrible the "replace DLL" workaround, so I did my best to come out with a safer solution... Luckily enough, I actually found two of them.


    Solution 1

    Apply the following MS HotFix, which fixes the issue for good:

    https://support.microsoft.com/en-us/help/2968741/error-0x80070057-when-sql-server-communicates-to-a-web-server-using-st

    (read the post for further info and to request the hotfix via e-mail through MS secure channels)

    Solution 2

    If you can't apply the HotFix, you can still get the job done by using a slightly different syntax when issuing the SEND command. Instead of this:

    Exec @ErrCode=sp_OAMethod @Object, 'send',null,'your-data';

    do this:

    Exec @ErrCode=sp_OAMethod @Object, 'send("your-data")';

    It works for any type of HTTP request data: JSON, XML and even application/x-www-form-urlencoded for standard POST request. The downside is that such syntax is quite ugly... and you have to change all your Stored Procedures that way.

    For additional info regarding the issue you can also read this post:

    http://www.ryadel.com/en/msxml2-xmlhttp-serverxmlhttp-error-0x80070057-parameter-incorrect-post-http-request-t-sql-server-2008-2012-sp-fix/


    Saturday, July 8, 2017 12:41 AM
  • Could you please send me the SOAP.DLL file to email doug_deneau@hotmail.com?

    Thank you.

    Wednesday, September 12, 2018 12:10 PM
  • I am very interested in your SOAP.dll, can you send me a copy? E-MAIL: mr.muqw@gmail.com
    Monday, December 3, 2018 3:09 AM
  • Good day Giancarlo, 

    Please send me the dll as well, I have logged a new threat and Im sure your dll could resolve: 

    https://social.technet.microsoft.com/Forums/en-US/a6e5a032-bd45-4967-9186-8d291ed4a917/soap-web-service-not-working-with-windows-server-2012-ampamp-sql-server-2012?forum=sqldataaccess

    Please send to :

    tertius@gvdm.co.za 

    Will be appreciated. 

    Thank you. 

    Wednesday, October 23, 2019 1:26 PM