First thing to be aware of is you may encounter issue if the webservice returns XML, so have it return a string instead. This is easily done by using a wrapper function. For example, if you have a webmethod say getLotData, just create a getLotDataStr as follows:
To consume the webservice, in vbscript or VB, you then use the MSSoap client as follows:
<WebMethod()> _
Public Function getLotData(ByVal pLotID As String) As XmlDocument
....
End Function
...
<WebMethod()>
Public Function getLotDataStr(ByVal pLotID As String) As String
Dim tmpStr As String = ""
Dim xDoc As XmlDocument
xDoc = getLotData(pLotID)
tmpStr = xDoc.OuterXml
Return tmpStr
End Function
Once the information is loaded to the XmlDocument, you can then access the information by using the getElementsByTagName. You can also access the inner text by access the Text Property.
Dim wsClient As New MSSOAPLib30.SoapClient30
Dim urlStr as String = "http://www.blogger.com/wservice.asmx?WSDL"
Dim sReply, lotID As String
Dim xDoc As DOMDocument30
lotID = ...
wsClient.MSSoapInit urlStr
sReply = wsClient.getLotDataStr(lotID)
xDoc.loadXML sReply
...
E.g.
You can also use the DomDocument30 data type to create the parameters if the Webservice requires a XML as a parameter.
Dim lotNode As IXMLDOMNode
Dim processStep As String
Set lotNode = xDoc.getElementByTagName("processID")
ProcessStep = lotNode.Text
'If it is an attribute then access it by the Attributes as in
ProcessStep = lotNode.Attributes.getNameItem("Name").Text
No comments:
Post a Comment