日期:2014-05-17  浏览次数:20920 次

asp 调用webservice
http://221.204.249.205:8080/veSWScn/veSWScn.dll?Handler=GenveSWScnWSDL

这个地址用asp如何调用获取返回数据

------解决方案--------------------
VBScript code

<%
Public Function SendHTTP(Method, URL, SendData,sCharset)
    On Error ReSume Next
    Dim HTTP    
    Set HTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")        
        HTTP.setTimeouts 10000,10000,10000,30000 
        HTTP.Open Method, URL, false, "", ""
        Http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
        HTTP.send SendData    
    
    If Err.Number = 0 then
        If HTTP.Readystate = 4 then
            If HTTP.Status = 200 Then
                SendHTTP = BytesToBSTR(HTTP.ResponseBody,sCharset)
            Else
                SendHTTP = ""
            End If
        Else
            SendHTTP = ""
        End If
    Else
        SendHTTP = ""
    End If
    Err.Clear
    Set HTTP = nothing
End Function

Public Function BytesToBSTR(Body,nCharset)
    If Not LenB(Body) = 0 then
        Dim ObjStream
        Set ObjStream = Server.CreateObject("Adodb.Stream")
        ObjStream.Type = 1
        ObjStream.Mode = 3
        ObjStream.Open
        ObjStream.Write body
        ObjStream.Position = 0
        ObjStream.Type = 2
        ObjStream.Charset = nCharset
        BytesToBSTR = ObjStream.ReadText 
        ObjStream.Close
        set ObjStream = Nothing
    Else
        BytesToBSTR = ""
    End IF
End Function

Dim ReturnValue,SendUrl
SendUrl="http://221.204.249.205:8080/veSWScn/veSWScn.dll?Handler=GenveSWScnWSDL"
ReturnValue = SendHTTP("GET",SendURL,null,"utf-8")

Dim YouWantDaTa,tiaojian
tiaojian="RtPnrIn"
If not ReturnValue="" Then
    dim XmlDoc,InfoXmlData                        
    Set XmlDoc = Server.CreateObject("msxml2.FreeThreadedDOMDocument.3.0")
    XmlDoc.ASYNC = False    
    
    XmlDoc.loadxml(ReturnValue)
    IF Not XmlDoc Is Nothing then            
                set InfoXmlData=XmlDoc.selectSingleNode("//definitions")
                IF not InfoXmlData is nothing then                    
                    YouWantDaTa=InfoXmlData.selectSingleNode("......")  '这里你自己查怎么,获取节点
                    response.Write(YouWantDaTa)
                    response.End()
                Else
                    RemoteADGetData = ""
                End if
    Else
        RemoteADGetData = ""
    End If
Else
    RemoteADGetData = ""
End If
%>

------解决方案--------------------
要递交SOAP头才可以
XML code

<S:Envelope
    xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:XS="http://www.w3.org/2001/XMLSchema"
    xmlns:XI="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:a="urn:veSWScnService"><S:Body><a:PAT S:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><a:bstrSS XI:type="XS:string">test</a:bstrSS><a:bstrPAT XI:type="XS:string">test</a:bstrPAT><a:strUser XI:type="XS:string">test</a:strUser></a:PAT></S:Body></S:Envelope>