Jump to content
Fórum Script Brasil
  • 0

Acesso WebService


Pessoal, boa noite.


Estou tendo dificuldades para acessar um webservice, toda vez que eu rodo a query o retorno é a estrutura do WSDL.


DECLARE @URI VARCHAR(2000) = 'https://www.cnj.jus.br/improbidade_adm/ws_server.php?wsdl'      
DECLARE @requestBody VARCHAR(8000) = 
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ws="http://www.cnj.jus.br/improbidade_adm/ws_server.php">
DECLARE @SoapAction VARCHAR(255) = 'http://www.cnj.jus.br/improbidade_adm/ws_server.php#pesquisarRequerido'
DECLARE @methodName varchar(50) = 'POST' 
DECLARE @objectID int
DECLARE @hResult int
DECLARE @statusText varchar(1000)
DECLARE @status varchar(1000) 
DECLARE @len INT = LEN(@requestBody)

EXEC @hResult = sp_OACreate 'MSXML2.XMLHTTP', @objectID OUT
EXEC @hResult = sp_OAMethod @objectID, 'OPEN', null, @methodName, @URI, 'false', '',''
EXEC @hResult = sp_OAMethod @objectID, 'setRequestHeader', null, 'soapAction', @SoapAction 
EXEC @hResult = sp_OAMethod @objectID, 'setRequestHeader', null, 'Content-Length', @len
EXEC @hResult = sp_OAMethod @objectID, 'setRequestHeader', null, 'Content-Type', 'text/xml; charset=utf-8'
EXEC @hResult = sp_OAMethod @objectID, 'SEND', null, @SoapAction [email protected] 
-- status 
EXEC sp_OAGetProperty @objectID, 'StatusText', @statusText out
EXEC sp_OAGetProperty @objectID, 'Status', @status out

INSERT @tabela ( CampoXML )
EXEC sp_OAGetProperty @objectID, 'responseXML.xml'

SELECT * FROM @tabela
SELECT @status [status], @statusText [statusText], @methodName [metodo]

EXEC sp_OADestroy @objectID 

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Cloud Computing

  • Forum Statistics

    • Total Topics
    • Total Posts
  • Create New...