Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP MSSoap.SoapClient30
Message
 
To
11/12/2017 11:44:01
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
01656273
Message ID:
01656402
Views:
80
Using automated tooling - if possible - is the way to do this. The SOAP Toolkit is so old and dated that it can't deal with many schema considerations, but it's always worth a try at least.

If at all possible though I would recommend not going down the 'manual' parsing approach. Web Services tend to be very complex in terms of how data gets passed and returned. Namespaces are a royal pain in particular and that can change the next time the service provider rebuilds their service even if functionally nothing changes. Hand coding stuff like this tends to be tedious and difficult to maintain even though it may seem easy on the surface. So I'd recommend using automated tooling **if at all possible**.

For Windows the easiest thing is usually to use .NET either directly or by using a tool like my company's West Wind Web Service Proxy Generator which uses .NET to create the service and the wraps the service with some additional helpers and a FoxPro class that can call the service, as well as the interop tools in order to deal with types that FoxPro natively can't do. FWIW, my tool just makes this easier - you can do all of this yourself and wwDotnetBridge (the interface that provide the .NET support features) is open source and free anyway. There are other tools for python, PHP etc. that can also call Web Services but it's not easy to integrate with that from FoxPro code, so .NET is generally the easiest approach.

All that said, just this week I ran into 2 services that .NET (or anything but SOAPUI!) couldn't handle either. The variety of crap Web services (this one was implemented in PHP) that exist is tremendous and there are no 100% automated solutions although in my experience between using .NET Web Service CLient (WSDL.exe) or WCF my success rate tends to be around 95% which I suppose is decent.

For more info on using .NET for FoxPro Web Service access check out this White Paper from my SW Fox session a couple of years ago:

Creating and Consuming Web Services using .NET

+++ Rick ---


>Good Afternoon Dear Experts.
>
>I am trying to set up a VFP communication with a Webservice WSDL.
>At the same time, I'm developing in .NET and I have the following code:
>
>
>        Dim client As ISession2.Session2Client = New ISession2.Session2Client()
>        Dim session As ISession2.SessionOpenResult = client.Open(Nothing, ISession2.WsRemoteClientTypes.WebserviceClient)
>        If (session.ErrorMessage Is Nothing And session.SessionId IsNot Nothing And session.Status = "cmdDone") Then
>            Dim logOnArgs As ISession2.SessionLogOnArgs = New ISession2.SessionLogOnArgs()
>            logOnArgs.UserName = "WebService"
>            logOnArgs.UserPassword = "password"
>            logOnArgs.StationName = "WebService"
>            logOnArgs.OwnerName = Nothing
>
>            Dim logOn As ISession2.SessionLogOnResult
>            logOn = client.LogOn(session.SessionId, logOnArgs)
>
>            If (logOn.ErrorMessage = Nothing And logOn.Status = "cmdDone") Then
>                Dim sessionID = New Guid(session.SessionId)
>                Dim material = New IMaterial.MaterialClient()
>
>                Dim getMaterialResult = material.MaterialExists(sessionID, "materialID")
>                If (getMaterialResult IsNot Nothing) Then
>                    MsgBox("material  found")
>                Else
>                    MsgBox("material not found")
>                End If
>            Else
>                MsgBox("Error Log On: " & logOn.ErrorMessage)
>            End If
>
>        Else
>            MsgBox("Error Opening: " & session.ErrorMessage)
>        End If
>
>        client.Close(session.SessionId)
>
>
>How can I translate this code into VFP?
>At this point I already have the following, but it is giving error in line 22:
>
>If(Alltrim(m.m_chinis)=='bl')
>	Local WSsession
>	Local oldSessionID
>
>	oWS = Createobject("MSSoap.SoapClient30")
>	oWS.MSSoapInit("http://10.0.0.1:1353/GP.CrossEnterpriseUnit.Integrator/ISession2?wsdl")
>
>	WSsession = oWS.Open(oldSessionID, "WebserviceClient")
>	WSsessionResult = get_nodeValue_from_xml(WSsession.Item(0).ParentNode.XML,"a:Status")
>	If(WSsessionResult=='cmdDone')
>		WS_SessionId = get_nodeValue_from_xml(WSsession.Item(0).ParentNode.XML,"a:SessionId")
>
>		msg(WS_SessionId)
>
>		Try
>			StationName = "WebService"
>			UserName = "WebService"
>			UserPassword = "Rmn123@456-"
>
>		
>
>			WSLogOn = oWS.LogOn(WS_SessionId, "StationName="+StationName+"&UserName="+UserName+"&UserPassword="+UserPassword)
>			WSLogOnResult = get_nodeValue_from_xml(WSLogOn.Item(0).ParentNode.XML,"a:Status")
>			msg(WSLogOnResult)
>
>		Catch To oError
>			msg("Linha " + astr(oError.Lineno) + Chr(13) + oError.Message)
>		Endtry
>
>	Else
>		WS_Error = get_nodeValue_from_xml(WSsession.Item(0).ParentNode.XML,"a:ErrorMessage")
>		msg(WS_Error)
>	Endif
>
>Endif
>
>Function get_nodeValue_from_xml
>	Lparameters myXML, myNodeName
>	oXML= Createobject("MSXML2.DomDocument")
>	oXML.LoadXML(myXML)
>
>	oRootNode = oXML.documentElement
>
>	* What is the root tag name?
>	cRootTagName = oRootNode.tagName
>
>	* Get all the nodes in the document with the special '*'
>	* parameter, we could just pass in a tag name to get the
>	* node list for that specific tag
>	oNodeList = oRootNode.getElementsByTagName("*")
>
>	* How many nodes did we retrieve
>	nNumNodes = oNodeList.Length
>
>	For nPos = 0 To (nNumNodes-1) Step 1
>
>		* Get the next node in the list
>		oNode = oNodeList.Item(nPos)
>		If(Alltrim(oNode.nodeName)==myNodeName)
>			Return Alltrim(astr(oNode.Text))
>		Endif
>	Endfor
>	Return ''
>
>
>The message says:
>OLE IDispatch exception code 0 from?: The formatter issued an exception while trying to undo the serialization of the message: An error occurred while trying to unsubscribe from the http://tempuri.org/:logOnArgs parameter. The InnerException message was' Error at line 1 position 561. Waiting for the 'Element' state. Found 'Text' with the name '', namespace ''. '. See InnerException for more details ...
>
>Thanks so much for your help!
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform