title: Call webservice from SQL stored procedure and want to know ResponseText Charset
body: <p>I want to call a webservice from my stored procedure and get an XML answer. I can get XML answer OK but I want to change responsetext charset utf-8 or euc-kr. How to change the responsetext charset? </p>
  
  <p>Ps. I Used [sp_OACreate 'ADODB.Stream'] but couldn't get responsebody
  so I want to  charset responsetext utf-8 or euc-kr </p>
  
  <p>This is what my stored procedure looks like:</p>
  
  <pre><code>        DECLARE @Object       INT 
                    , @hResult       INT
                    , @source        NVARCHAR(255)
                    , @desc           NVARCHAR(255)
                    , @Method     NVARCHAR(MAX) 
                    , @ResponseText     VARCHAR(MAX) 
                    , @ResponseBody     varbinary(MAX) 
              DECLARE @ObjectToken INT
  
               -- OLE 호출 --XML
              EXEC @hResult = sp_OACreate 'MSXML2.ServerXMLHTTP', @Object OUT;
  
              EXEC @hResult = sp_OAMethod @Object, 'open', NULL, 'GET',@URL,0--'false'                                                                                                  
              Exec sp_OAMethod @Object ,'setRequestHeader'    ,NULL ,'Content-Type' ,'text/xml; charset=utf-8'
              EXEC @hResult = sp_OAMethod @Object, 'send'
  
              EXEC sp_OAGetProperty  @Object, 'ResponseText'--,@ResponseBody OUT
  
  
              EXEC sp_OADestroy @Object 
              --SELECT @ResponseBody AS ResponseBody
  
  
  
              RETURN 
               -- OLE -ADODB
              EXEC sp_OACreate 'ADODB.Stream', @ObjectToken OUTPUT
              EXEC sp_OAMethod @ObjectToken, 'Open'
              EXEC sp_OASetProperty @ObjectToken, 'Position ', 0                
              EXEC sp_OASetProperty @ObjectToken, 'Type', 1
              EXEC sp_OASetProperty @ObjectToken, 'Write', NULL,@ResponseBody
              EXEC sp_OASetProperty @ObjectToken, 'Position ', 0                
              EXEC sp_OASetProperty @ObjectToken, 'Type', 2               
              EXEC sp_OASetProperty @ObjectToken, 'Charset ', 'euc-kr'    
  
              EXEC sp_OAMethod @ObjectToken, 'ReadText'
  
              EXEC sp_OAMethod @ObjectToken, 'Close'
  
  
             --EXEC @hResult =   sp_OAMethod @Object, 'ResponseText'--, @ResponseText OUTPUT
  
  
          --   INSERT INTO TempReceiveXml_Body 
          --   exec sp_OAMethod @Object, 'responsebody'
  
              EXEC sp_OADestroy @Object 
              EXEC sp_OADestroy @ObjectToken    
  </code></pre>