接口文件格式说明(asp+xmlhttp)

来源:互联网 发布:qq飞车迈凯轮数据 编辑:程序博客网 时间:2024/05/02 02:13

 

接口xml文件格式

 

<info>

<rec>

       <depID>所属栏目</depID>

       <smallClassID>所属信息单位</smallClassID>

       <type>信息发布形式</type>

<keyWord>关键字</keyWord>

<title>新闻标题</title>

<author>作者</author>

<original>原出处</original>

<content>新闻内容</content>

</rec>

<rec>

       <depID>所属栏目</depID>

       <smallClassID>所属信息单位</smallClassID>

       <type>信息发布形式</type>

<keyWord>关键字</keyWord>

<title>新闻标题</title>

<author>作者</author>

<original>原出处</original>

<content>新闻内容</content>

</rec>

</info>

 

注:接口类型和数据注意事项。

 

字段名

名称

类型

数据取值说明

上传数据说明

depID

所属栏目

Int(4)

 

代码(不能为空)

smallClassID

所属信息单位

Nvarchar(25)

 

代码(不能为空)

type

信息发布形式

Nvarchar(7)

重要信息=1

弹出信息=2

热点信息=3

可复选多个,以“,”分隔

如:1,2,3

代码(多个用逗号分隔)

keyWord

关键字

Nvarchar(50)

多个以“,”分隔

如:keyword1,keyowrd2

文字(多个用逗号分隔)

title

新闻标题

Nvarchar(50)

文字

文字(不能为空)

author

作者

Nvarchar(20)

文字

文字

original

原出处

Nvarchar(20)

文字

文字

content

新闻内容

varChar (4000)

文字

文字(不能为空)

 

 

 

举例:

<info>

<rec>

       <depID>1</depID>

       <smallClassID>20040212200856429814</smallClassID>

       <type>1,3</type>

<keyWord>关键字1, 关键字2</keyWord> 

<title>新闻标题</title>

<author>作者</author>

<original>原出处</original>

<content>新闻内容</content>

</rec>

</info>

 

 

上传方法说明:

 

将上述产生的字符串发送到http://服务器IP:端口/receiveInfo.asp(必须用POST方式传送)

 

经测试通过代码如下:

 

发送端:sendInfo.asp

 

<%

set xmlhttp=Server.CreateObject("MSXML2.ServerXMLHTTP")

 

xmlstr="<info><rec><depID>1</depID><smallClassID>20040212200856429814</smallClassID><type>1,3</type><keyWord>关键字1, 关键字2</keyWord><title>新闻标题</title><author>作者</author><original>原出处</original><content>新闻内容</content></rec></info>"

 

URL="http://192.168.1.5:9020/receiveInfo.asp"

xmlhttp.open "POST",URL, False

xmlhttp.send  xmlstr

if  err.number=0 then

       if xmlhttp.status <>"200" then

              Response.Write "<font style='font-size:12px;color:red'>状态:"&xmlhttp.status&" ;描述:"&xmlHttp.ResponseText&"</font>"

       else

              Response.Write "<font style='font-size:12px;color:red'>  "&xmlHttp.ResponseText&"</font>"

       end if

else

       Response.Write "<font style='font-size:12px;color:red'>状态:"&xmlhttp.status&" ;描述:"&xmlHttp.ResponseText&"</font>"

end if

%>

 

 

 

接收端:receiveInfo.asp

 

 

<%@codepage=936%>

<%

Server.ScriptTimeOut=99999

Response.Buffer =false

Response.CharSet="gb2312"

set xmldoc=Server.CreateObject("MSXML2.DOMDocument")

 

xmldoc.load Request

 

set root = xmldoc.DocumentElement

 

for i=1 to xmldoc.documentelement.childNodes.length

 

Set recnote = xmldoc.documentelement.childNodes(i-1)

 

Set depIDnote = recnote.selectSingleNode("depID")

Set smallClassIDnote = recnote.selectSingleNode("smallClassID")

Set typenote = recnote.selectSingleNode("type")

Set keyWordnote = recnote.selectSingleNode("keyWord")

Set titlenote = recnote.selectSingleNode("title")

Set authornote = recnote.selectSingleNode("author")

Set originalnote = recnote.selectSingleNode("original")

Set contentnote = recnote.selectSingleNode("content")

 

response.Write depIDnote.text&"||"

response.Write smallClassIDnote.text&"||"

response.Write typenote.text&"||"

response.Write keyWordnote.text&"||"

response.Write titlenote.text&"||"

response.Write authornote.text&"||"

response.Write originalnote.text&"||"

response.Write contentnote.text&"||"

 

 

next

 

response.Write("0")

 

%>

原创粉丝点击