2009-04-20 10 views
1

Le code suivant ne fonctionne pas pour moi sur Win Server 2003 mais fonctionne sur XP. J'ai installé SOAP Toolkit 3.0 sur le serveur. Qu'est-ce qui pourrait être une raison?Consommez webservice en ASP classique

+0

Avez-vous essayé d'exécuter le script sur la machine Windows Server 2003 en dehors de IIS, à savoir remplacer Server.CreateObject avec CreateObject et Response.Write avec MsgBox et enregistrer en tant que VBS? Cela devrait vous indiquer si le serveur est capable de créer les objets sans impliquer IIS. – boflynn

+0

J'ai essayé le code dans le fichier .vbs. Il me donne l'erreur que: Le composant ActiveX ne peut pas créer l'objet: 'MSSOAP.SoapClient30' –

+0

J'ai un problème similaire avec Windows Server 2008 64 bits. Est-ce que votre serveur a aussi le problème? –

Répondre

4

« Voici une autre façon de consommer un service Web .NET en ASP classique.

<html> 
    <head><title></title></head> 
    <body> 


    <%  
     Dim objHTTP, strEnvelope 
     Set objHTTP = Server.CreateObject("Microsoft.XMLHTTP") 

     'Create the SOAP Envelope. 
     'Start with standard xml name space and XML Schema Definition. 
     strEnvelope = "<?xml version='1.0' encoding='utf-8'?>" 
     strEnvelope = strEnvelope & "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" 

     'Define body of SOAP with method name and parameter names and vlaues to be passed. 
     strEnvelope = strEnvelope & "<soap:Body>" 
     strEnvelope = strEnvelope & "<AuthenticateUser xmlns='http://wwwte.abc.com/cpp'>" 
     strEnvelope = strEnvelope & "<db>1</db>" 
     strEnvelope = strEnvelope & "<_username>MYUSERNAME</_username>" 
     strEnvelope = strEnvelope & "<_password>MYPASSWORD</_password>" 
     strEnvelope = strEnvelope & "</AuthenticateUser>" 
     strEnvelope = strEnvelope & "</soap:Body></soap:Envelope>"  

     'Set properties of HTTP object and send SOAP envelop while calling 'Send' method 
     Dim url 
     url = "http://cpp.abc.com/cpp/CPPLDAP/CPPLDAP.asmx" 
     With objHTTP 
      .Open "post", url, False 
      .setRequestHeader "Content-Type", "text/xml; charset=utf-8" 
      .setRequestHeader "SOAPAction", "http://wwwte.abc.com/cpp/AuthenticateUser" 
      .send strEnvelope 
     End With 
     ' Following will write xml received from web services in the browser 
     Dim strResponse 
     strResponse = objHTTP.responseXML.Text 
     If (strResponse = "") Then 
      Response.Write("Invalid user") 
     Else   
      Set myXmlDoc = Server.CreateObject("MSXML2.DOMDocument") 
      myXmlDoc.loadXML (strResponse) 
      Set objLst = myXmlDoc.getElementsByTagName("directoryEntry") 
      Set objListNodes = objLst.Context.childNodes(0).childNodes 
      For i = 0 To (objListNodes.Length - 1) 
       Response.Write(objListNodes.Item(i).nodeName & ":------ " & objListNodes.Item(i).Text) 
       Response.Write("</BR>") 
      Next 
     End If 

    %> 


    </body> 
</html> 
+0

il est bon d'avoir une réponse complète, mais s'il vous plaît consulter [this] (http://stackoverflow.com/a/11251/443685) avertissement sur Microsoft.XMLHTTP –