aspはjsonを介してwebserviceインターフェイスを呼び出し、返されたxmlデータと分析を取得します

この場合、aspはwebserviceインターフェースを呼び出し、返されたXMLデータと分析を取得します!


<!-#インクルードファイル= "conn.asp"->
<!-#インクルードファイル= "md532.asp"->

<!-#インクルードファイル= "SYS_INCLUDE_HTML.ASP"->

<%   
Response.Write "Test time:"&now()& "<br>"
dim url、SOAPAction、HOST
url = "http://192.168.17.71/KDWebservice/KDService.asmx?op=CreateCust" // webserbiceaddress = number続いて、インターフェースのメソッド
Host = "192.168.17.71" // ip address
SOAPAction = "http://tempuri.org/CreateCust" // CreateCustをメソッドに置き換えます

dim stringJS
custno = request( "custno")
key = " 16394 "
strtoken = custno&key
token = md5(strtoken、32、



sql = "select * from [customer] where custno = '"&custno& "'"
rs.open sql、conn、1,1
if not rs.eof then
    fCustNo = rs( "custno")
    fCustName = rs( "cmingcheng")
if
rs.close

stringJS = "{'token': '"&token& "'、 'head':{'fCustNo': '"&fCustNo& "'、 'fCustName': '"&fCustName& "'}}" //これはデータ接続のjsonを取得します。自己のjson
Response.Write stringJS& "<br>"


SoapRequest = "<?xml version ="&CHR(34)& "1.0"&CHR(34)& "encoding ="&CHR (34)& "utf-8"&CHR(34)& "?>"& _
"<soap:Envelope xmlns:xsi ="&CHR(34)& "http://www.w3.org/2001/XMLSchema-instance"&CHR(34)& ""&_
"xmlns:xsd ="&CHR( 34)& "http://www.w3.org/2001/XMLSchema"&CHR(34)& ""&_
"xmlns:soap ="&CHR(34)& "http://schemas.xmlsoap.org/soap/envelope/"&CHR(34)& ">"&_
"<soap:Body>"&_
"<CreateCust xmlns = "&CHR(34)&" http://tempuri.org/ "&CHR(34)&"> "&_ //把CreateCust替换你的方法
" <json> "&stringJS&" </ json> "&_   
" </ CreateCust> "&_ //把CreateCust替换你的方法
" </ soap:Body> "&_
" </ soap:Envelope> "

Set xmlhttp = server.CreateObject(" Msxml2.XMLHTTP ")
xmlhttp.Open" POST "、url、false
xmlhttp.setRequestHeader" Content-Type "、" text / xml; charset = utf-8 "
xmlhttp.setRequestHeader "HOST"、ホスト
xmlhttp.setRequestHeader "Content-Length"、LEN(SoapRequest)
xmlhttp.setRequestHeader "SOAPAction"、SOAPAction

// 'WEBSERVICEネームスペースと同じである必要があります。それ以外の場合、サービスは拒否されます   


xmlhttp.Send(SoapRequest)
   
// 'XMLHTTPを使用して、SOAPの例に一致するSOAPリクエストを正常に送信します。// '成功した   
かどうかを確認します   
。Response.Write "Status:"&xmlhttp.Status& "<BR>"
Response。 "StatusText:"&xmlhttp.StatusText& "<BR>"を

書き込みます。xmlhttp.status= 200の場合、      
    xmldoc = server.createobject( "msxml2.domdocument")     
    xmldoc.load(xmlhttp.responsexml)を設定します
    // xmldocはWebサービスによって返されますxmlコンテンツ。Web
    
    サービスがxmlを返さない場合は、xmlhttp.responsetext objNodes = xmldoc.getElementsByTagName( "root / msgType")
     Response.Write "Status:"&objNodes& "<BR>"
     
     sendMessageByPhone = xmldoc.documentElement.selectNodes( "を使用します。 //root//msgType")(0).text // xmlルートを解析する最初のノードmsgType 2番目のノード
    Response.Write "msgType:"&sendMessageByPhone& "<BR>"
    
    sendMessageByPhone = xmldoc.documentElement.selectNodes( "// root // msgstring")(0).text
    Response.Write "msgstring:"&sendMessageByPhone& "<BR>"
            
else
    Response .Write xmlhttp = Nothing    %>の   
場合、「Write用webservice失败」で 終了

    





21件のオリジナル記事を掲載 21件の賞賛 40,000回以上の閲覧

おすすめ

転載: blog.csdn.net/kuyz1/article/details/54585039