Question : Call a WCF Service from VBScript

Hi,

I've written a WCF service that receives 4 bits of data from client machines and saves them to a DB.  This is used for saving server diagnostic check results.
The Method on the service is saveCheckData int, int, string, string.

The WSDL for the service is attached (snippet 653160)

I've found some code on stack overflow (snippet 653202), but can't figure out how to specify my method and it's parameters.

Any help appreciated.

Thanks

Mick
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
<?xml version="1.0" encoding="utf-8" ?> 
- <wsdl:definitions name="eqSysCheckServiceImplementation" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:i0="net.stinkyfinger.eqSysCheckService" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
  <wsdl:import namespace="net.stinkyfinger.eqSysCheckService" location="http://server.mydomain.net/eqSysCheck/eqSysCheckService.svc?wsdl=wsdl0" /> 
  <wsdl:types /> 
- <wsdl:binding name="BasicHttpBinding_eqSysCheckServiceContract" type="i0:eqSysCheckServiceContract">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
- <wsdl:operation name="saveCheckData">
  <soap:operation soapAction="net.stinkyfinger.eqSysCheckService/eqSysCheckServiceContract/saveCheckData" style="document" /> 
- <wsdl:input>
  <soap:body use="literal" /> 
  </wsdl:input>
+ <wsdl:output>
  <soap:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:service name="eqSysCheckServiceImplementation">
+ <wsdl:port name="BasicHttpBinding_eqSysCheckServiceContract" binding="tns:BasicHttpBinding_eqSysCheckServiceContract">
  <soap:address location="http://server.mydomain.net/eqSysCheck/eqSysCheckService.svc" /> 
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
url= "http://server:port/Wcf.Service.Address" 
 
Dim requestDoc 
Set requestDoc = WScript.CreateObject("MSXML2.DOMDocument.6.0") 
 
Dim root 
Set root = requestDoc.createNode(1, "Envelope", "http://schemas.xmlsoap.org/soap/envelope/") 
requestDoc.appendChild root 
 
Dim nodeBody 
Set nodeBody = requestDoc.createNode(1, "Body", "http://schemas.xmlsoap.org/soap/envelope/") 
root.appendChild nodeBody 
 
Dim nodeOp 
Set nodeOp = requestDoc.createNode(1, "Register", "urn:Your.Namespace.Here") 
nodeBody.appendChild nodeOp 
 
Dim nodeRequest 
Set nodeRequest = requestDoc.createNode(1, "request", "urn:Your.Namespace.Here") 
'content of the request will vary depending on the WCF Service.' 
' This one takes just a plain string. ' 
nodeRequest.text = "Hello from a VBScript client." 
 
nodeOp.appendChild nodeRequest 
 
Set nodeRequest = Nothing 
Set nodeOp = Nothing 
Set nodeBody = Nothing 
Set root = Nothing 
 
 
'the request will look like this:' 
'       <s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'> ' 
'         <s:Body> ' 
'           <Register xmlns='urn:Your.Namespace.Here'> ' 
'               <request>hello from a VBScript client.</request> ' 
'           </Register> ' 
'         </s:Body> ' 
'       </s:Envelope>' 
 
 
WSCript.Echo  "sending request " & vbcrlf & requestDoc.xml 
 
 
dim xmlhttp 
 
set xmlhttp = WScript.CreateObject("MSXML2.ServerXMLHTTP.6.0") 
' set the proxy as necessary and desired ' 
xmlhttp.setProxy 2, "http://localhost:8888" 
xmlhttp.Open "POST", url, False 
xmlhttp.setRequestHeader "Content-Type", "text/xml" 
' set SOAPAction as appropriate for the operation ' 
xmlhttp.setRequestHeader "SOAPAction", "urn:Set.As.Appropriate" 
xmlhttp.send requestDoc.xml 
 
WScript.Echo vbcrlf & "Raw XML response:" & vbcrlf  
WSCript.Echo  xmlhttp.responseXML.xml 
 
dim response 
set response= xmlhttp.responseXML 
'the response is an MSXML2.DOMDocument.6.0'  
'party on the response here - XPath, walk the DOM, etc. '

Answer : Call a WCF Service from VBScript

Random Solutions  
 
programming4us programming4us