经典的ASP和Web服务-如何使其与Java一起使用?

时间:2018-08-14 13:13:14

标签: java web-services soap asp-classic xmlhttprequest

我已经接管了用经典ASP编写的旧应用程序,该应用程序使用2种不同的Web服务来发布和接收来自其的响应。

Web服务A在ASP中完成。在IE和Chrome中都可以正常运行。

Web服务B也在ASP中完成。在IE中工作正常,在Chrome中没有响应。我在Java中重新设置了它,但在IE中却给出了Security warning,而在Chrome中什么也没发生。 Web服务B也会在响应中调用Web服务。

我真的希望Web服务在两个浏览器中都可以工作,而不会弹出警告,因为随着时间的流逝,这真的很烦人。

我在做什么错?我不明白为什么服务A可以正常工作,但服务B却不能正常工作。

Web服务A

Set oXmlHTTP = CreateObject("Microsoft.XMLHTTP")
oXmlHTTP.Open "POST", "http://serviceA?wsdl", False 
oXmlHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8" 
oXmlHTTP.setRequestHeader "SOAPAction", "urn:requestA"

SOAPRequest = [XMLRequest]

On Error Resume Next
oXmlHTTP.send SOAPRequest   

If Err.Number Then 
'Do something
Err.Clear 
Else 
SOAPResponse = oXmlHTTP.responseXML.text

End If 
On Error Goto 0 


If LEN(SOAPResponse) > 0 Then
Set objxml = Server.CreateObject("MSXML2.DOMDocument")
objxml.async = False
objxml.load (oXmlHTTP.responseXML)      

If objxml.parseError.errorCode <> 0 Then
     'handle the error
End If

Set nodeList = objxml.getElementsByTagName("TagName")
SizeofObject = nodeList.length-1
For i = 0 To (SizeofObject)

    'get individual element

Next    

Set oXmlHTTP = nothing 
SOAPRequest = ""
SOAPResponse = ""

Web服务B

Set oXmlHTTP = CreateObject("MSXML2.ServerXMLHTTP.3.0")
oXmlHTTP.open "POST", "http://serviceB?wsdl", False 
oXmlHTTP.setRequestHeader "Content-Type", "text/xml; charset=UTF-8" 

SOAPRequest = [XMLRequest]

On Error Resume Next
oXmlHTTP.send SOAPRequest   

If Err.Number Then 
    'Handle error
    Err.Clear 
Else 
    SOAPResponse = oXmlHTTP.responseText

End If 
On Error Goto 0 


if len(SOAPResponse) > 0 then
    Set objxml = Server.CreateObject("MSXML2.DOMDocument")
    objxml.async = False
    objxml.load (oXmlHTTP.responseXML)      

    If objxml.parseError.errorCode <> 0 Then
         'handle the error
    End If

    Set nodeList = objxml.getElementsByTagName("TagB1")
    SizeofObject = nodeList.length-1

    For i = 0 To (SizeofObject)  

        'get individual elements
        array(i)    = nodeList.item(i).Text

    Next    

    NextRequest(array)
else 
    'handle empty
end if
    Set oXmlHTTP = nothing 
    SOAPRequest = ""
    SOAPResponse = ""


Function NextRequest(inputArray())
If UBound(inputArray)>=0 Then

    For Each ele In inputArray
    Set oXmlHTTP2 = CreateObject("MSXML2.ServerXMLHTTP.3.0")
    oXmlHTTP2.Open "POST", "http://serviceB?wsdl", False 
    oXmlHTTP2.setRequestHeader "Content-Type", "text/xml; charset=UTF-8" 

    SOAPRequest2 =[XMLRequest2]

    On Error Resume Next
    oXmlHTTP2.send SOAPRequest2   

    If Err.Number Then 
        'Handle
        Err.Clear 
    Else 
        SOAPResponse2 = oXmlHTTP2.responseXML.text
    End If 
        On Error Goto 0 

    If Len(SOAPResponse2) > 0 then

        Set objxml2 = Server.CreateObject("MSXML2.DOMDocument")
        objxml2.async = False
        objxml2.load (oXmlHTTP2.responseXML)        

        'Fejlhåndtering af XML
        If objxml2.parseError.errorCode <> 0 Then
                 'handle the error
        End If

        Set nodeList = objxml2.getElementsByTagName("Tag2")
        SizeofObject = nodeList.length-1

            For j = 0 To SizeofObject
                Response.Write objxml2.getElementsByTagName("Tag2").item(j).Text
            Next 

    End If
    Next

    Set oXmlHTTP2 = nothing 
    SOAPRequest2 = ""
    SOAPResponse2 = ""
End Function

0 个答案:

没有答案