zoukankan      html  css  js  c++  java
  • 使用SQL Server连接xml接口,读取并解析数据

    --数据源格式,放到任意程序中部署接口即可
    --
    <Data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> --<Peoples> --<People> --<Name>张三</Name> --<Sex>男</Sex> --</People> --<People> --<Name>李四</Name> --<Sex>女</Sex> --</People> --<People> --<Name>王武</Name> --<Sex>男</Sex> --</People> --<People> --<Name>赵柳</Name> --<Sex>女</Sex> --</People> --<People> --<Name>武士刀</Name> --<Sex>男</Sex> --</People> --</Peoples> --</Data> --调用webService---------------- declare @ServiceUrl as varchar(1000) DECLARE @UrlAddress varchar(500) --WebService地址:以http开头,结尾带斜杠,例如'https://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/' set @UrlAddress = 'http://localhost:11687/home/webxml' SET @ServiceUrl=@UrlAddress--如果有参数可以在此处拼入 --访问地址获取结果 Declare @Object as Int Declare @ResponseText as Varchar(8000) --必须8000 Declare @Data as XML EXEC sp_OACreate 'MSXML2.XMLHTTP', @Object OUT; --创建OLE组件对象 Exec sp_OAMethod @Object, 'open', NULL, 'POST',@ServiceUrl,'false' --打开链接,注意是get还是post Exec sp_OAMethod @Object, 'send' EXEC sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT --输出参数 Select @ResponseText --输出结果 SET @Data = CAST(@ResponseText AS XML) select t.c.value('(Name/text())[1]','VARCHAR(20)') as Name, t.c.value('(Sex/text())[1]','VARCHAR(20)') as Sex from @Data.nodes('/*/*/*') as t(c) Exec sp_OADestroy @Object GO ----开启 Ole Automation Procedures --sp_configure 'show advanced options', 1; --GO --RECONFIGURE; --GO --sp_configure 'Ole Automation Procedures', 1; --GO --RECONFIGURE; --GO --EXEC sp_configure 'Ole Automation Procedures'; --GO ----关闭 Ole Automation Procedures --sp_configure 'show advanced options', 0; --GO --RECONFIGURE; --GO --sp_configure 'Ole Automation Procedures', 0; --GO --RECONFIGURE; --GO --EXEC sp_configure 'Ole Automation Procedures'; --GO
    ----开启Ad Hoc Distributed Queries组件,在sql查询编辑器中执行如下语句:
    --exec sp_configure 'show advanced options',1
    --reconfigure
    --exec sp_configure 'Ad Hoc Distributed Queries',1
    --reconfigure
    ----关闭Ad Hoc Distributed Queries组件,在sql查询编辑器中执行如下语句:
    --exec sp_configure 'Ad Hoc Distributed Queries',0
    --reconfigure
    --exec sp_configure 'show advanced options',0
    --reconfigure
    
    
    

     

     
  • 相关阅读:
    idea14导入eclipse项目并部署运行完整步骤
    Java之Socket
    Docker之宿主机ssh至docker容器
    ElasticSearch的安装、使用、踩坑
    Linux下grep、tail、wc、awk文件处理命令
    Spring中@Async注解实现“方法”的异步调用
    Thrift——栗子
    Linux中的守护进程——supervise
    【composer】 PHP composer 镜像地址更换
    【Mac】解决macos安装升级时报错安装所选更新时发生错误的问题
  • 原文地址:https://www.cnblogs.com/GoCircle/p/9401188.html
Copyright © 2011-2022 走看看