来自VBScript的Web服务调用

时间:2017-01-26 14:29:05

标签: web-services soap vbscript

我正在尝试从VBS调用webservice。我收到错误“行中的类型不匹配”objSOAP.sSOAPRequest =“。我尝试删除它的归档标记内的输入。然后这个错误不会来.codesBase64和fieldvalue2(它们位于存档和文件夹中的soap xml内部)标签分别是另一个vbs代码的输出,其中zip文件被转换为base64值(它的巨大).fieldvalue2是一个小字符串。

Class ServiceRequest 
 Private oWinHttp,sContentType 
 Public sWebServiceURL, sSOAPRequest,sResponse,servicename,sHost 

Private Sub Class_Initialize 
 Set oWinHttp = CreateObject("WinHttp.WinHttpRequest.5.1") 

'Web Service Content Type 
 sContentType ="text/xml;charset=UTF-8" 

End Sub 

Public Function SetSoapAction(servicename) 

sWebServiceURL = "http://s05ast0026-  c05.nl.eu.abnamro.com:12726/EngageOneWS/TemplateService" 
 End Function 

Public Function SendRequest 
 sHost="pb.com" 
 'Open HTTP connection  
oWinHttp.Open "POST", sWebServiceURL, False 

'Setting request headers  
oWinHttp.setRequestHeader "Content-Type", sContentType 

'Send SOAP request 
 oWinHttp.Send  sSOAPRequest 

'Get XML Response 
 sResponse = oWinHttp.ResponseText 
 End Function 

Public Function Close 
 Set oWinHttp = Nothing 
 End Function 


End Class 


    Set objSOAP = New ServiceRequest
    objSOAP.SetSoapAction("Bananas") ---- > simply passing can be avoided
    objSOAP.sSOAPRequest="<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://pb.com/EngageOne/ws/template"" xmlns:com=""http://pb.com/EngageOne/ws/common""><soapenv:Header/><soapenv:Body><tem:ImportTemplate><com:authContext><com:UsernameToken> <com:domain><com:ident><com:name>EngageOne</com:name></com:ident></com:domain><com:userId>s03217</com:userId><com:transientSession>false</com:transientSession><com:ondemand>false</com:ondemand></com:UsernameToken></com:authContext><com:context><com:domain><com:ident><com:name>EngageOne</com:name></com:ident></com:domain><com:user><com:id>s03217</com:id></com:user></com:context><archive>"&encodeBase64&"</archive><folder><ident><com:id></com:id><com:name>"& fieldvalue2 &"</com:name></ident></folder><effectiveDate>?</effectiveDate><withdrawnDate>?</withdrawnDate></tem:ImportTemplate></soapenv:Body></soapenv:Envelope>"



objSOAP.SendRequest 
 sResponse = objSOAP.sResponse
msgBox(sResponse)

0 个答案:

没有答案