要調用的接口方法:UP_ACC_inst_Info(string xml)
接口參數:xml格式的字符串
接口功能:傳遞人員編號、備注到接口進行更新,接口返回更新結果。
實例:
declare @strXML varchar(5000)declare @obj intdeclare @sUrl varchar(5000)declare @response varchar(5000)declare @hr int--參數SET @strXML ='<root><accountid>654</accountid> <innotes>654的備注</innotes></root>'
--將參數中的<,>轉換為轉義字符,否則接口無法把@strXML識別為string類型,會報400錯誤信息set @strxml=replace(@strXML,'<','<')set @strxml=replace(@strXML,'>','>')
--接口地址set @sUrl='http://localhost/WebService.asmx'--拼裝soap 1.2 格式信息set @strXML='<?xml version="1.0" encoding="utf-8"?><soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"><soap12:Body><UP_ACC_inst_Info xmlns="http://tempuri.org/"><strXML>'+@strXML+'</strXML></UP_ACC_inst_Info></soap12:Body></soap12:Envelope>'
exec sp_OACreate 'MSXML2.ServerXMLHttp', @obj out
exec sp_OAMethod @obj,'Open',null,'POST',@sUrl,FALSE
exec sp_OAMethod @obj,'setRequestHeader',null,'Content-Type','application/soap+xml; charset=utf-8'exec sp_OAMethod @obj,'Send',null,@strXMLexec sp_oagetPRoperty @obj,'status',@response outIF @hr <> 200BEGIN EXEC sp_OAGetErrorInfo @obj print @obj returnENDexec sp_oagetproperty @obj,'responseTEXT',@response out
--由于接口返回的結果也是xml格式的string,將里邊的<,>轉換回來set @response=replace(@response,'<','<')set @response=replace(@response,'>','>')print @responseexec sp_oadestroy @obj
新聞熱點
疑難解答