Page 1 of 1

SOAP WebService

PostPosted: Thu Mar 13, 2014 5:33 pm
by Marc Vanzegbroeck
Hello,

I need to send and receive some information to a SOAP webservice to connect my program to a Truck-tracking program.
I received this C-code from that company
Code: Select all  Expand view
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestWebservice
{
  class Program
  {
    static void Main(string[] args)
    {
      using (ServiceReference1.Service1Client myGeoPlanner = new ServiceReference1.Service1Client())
      {
        string login = "login";
        string password = "pasword";
        string exception = null;

        List<ServiceReference1.vehilcle> vehilcles = myGeoPlanner.GetVehicles(login, password, false, ref exception);

        int vehicleId = 100879;
        DateTime validFromDate = DateTime.Now;
        DateTime validToDate = DateTime.Now.AddDays(6);

        string codeClient = "789456";
        //bool exception6 = myGeoPlanner.CreateRegionCodeClientLatLon2(login, password, "Qeos Parking", "Enclus du Haut. 10", "", "7750", "Mont-de-L'Enclus", "BELGIUM", codeClient, 20, 50.756789181291943, 3.4804098796214475);

        //var routeId = myGeoPlanner.PutRoute(login, password, vehicleId, "test qeos", 21, validFromDate, validToDate, ref exception);
      }
    }
  }
}


Has anyone have done this allready?
Can anyone convert this to xHarbour?

Thanks,

Re: SOAP WebService

PostPosted: Fri Mar 14, 2014 2:53 pm
by James Bott
Marc,

Perhaps this old message thread will help.

viewtopic.php?f=3&t=18979

Regards,
James

Re: SOAP WebService

PostPosted: Fri Mar 14, 2014 3:26 pm
by James Bott
I don't see a URL in the sample you provided. Did they give you a URL, login, and password to test the system with? Or, possibly the test login and password is as shown in the sample--"login" and "pasword" (note only one s)? Still need a URL.

James

Re: SOAP WebService

PostPosted: Fri Mar 14, 2014 3:58 pm
by Marc Vanzegbroeck
James,

Thanks for the link. I already found this tread, but I don't know how to use it.
They also gave me a URL, but it's not in that code... I don't know whre to put the URL

I also found this tread http://forums.fivetechsupport.com/viewtopic.php?f=3&t=27333 but I can't compile the example. I get an error..

Re: SOAP WebService

PostPosted: Sat Mar 15, 2014 2:17 am
by James Bott
Marc,

I have only done some work with web services that didn't require a login so all I needed to do was read the XML page off the site.

To use a secure login you have to use the SOAP software (free download from Microsoft). It is actually an old technology so you will find the Microsoft says it was discontinued in 2005 (but it still appears to be available).

So, one reason the sample you tried to compile errored out was because you have to have SOAP installed. I think the sample you were trying also requires an SSL class that is a separate download (from I don't know where). I think it is a Harbour addon or xHarbour. Reinaldo Crespo seems to be the one to talk to. I suggest responding to the old thread to see if he answers, otherwise you can just email him (his address is in the thread).

Also, there is a good description of SOAP here:

http://msdn.microsoft.com/en-us/library/ms996507.aspx

James

Re: SOAP WebService

PostPosted: Mon Mar 17, 2014 4:51 pm
by Marc Vanzegbroeck
Hi,

I finaly can connect to the webservice :D

Code: Select all  Expand view
myGeoPlanner:= CreateObject("MSSOAP.SoapClient30")
myGeoPlanner:MSSoapInit(alltrim(UPurl))

vehilcles := myGeoPlanner:GetVehicles(login, password, .f., @fout)
msginfo(valtype(vehilcles))
 


The only problem is that I receive an object.
Any idea how to get the data.

This is the doc about the GetVehicles object
Code: Select all  Expand view
[OperationContract] List<vehilcle> GetVehicles(string login, string password, Boolean logical_deleted_include, ref string exception);

Boolean logical_deleted_include = True = Get active and not active vehicles False = Get only active vehicles ref string exception = If an error occurs the error or exception will be copied into the string exception.

Return: List<vehilcle> = List of vehicles


Thanks

Re: SOAP WebService

PostPosted: Mon Mar 17, 2014 7:12 pm
by James Bott
Marc,

Try:

Code: Select all  Expand view
vehilcles := myGeoPlanner:GetVehicles(login, password, .f., @fout)
oXml := TXmlDocument():New( vehilcles )
xbrowse( oXml )

I note that you have misspelled vehicle as "vehilcle."

James

Re: SOAP WebService

PostPosted: Mon Mar 17, 2014 7:18 pm
by Marc Vanzegbroeck
James Bott wrote:Marc,

Try:

Code: Select all  Expand view
vehilcles := myGeoPlanner:GetVehicles(login, password, .f., @fout)
oXml := TXmlDocument():New( vehilcles )
xbrowse( oXml )

I note that you have misspelled vehicle as "vehilcle."

James


Thanks James,
I will try it. vehilcle is not misspelled. 'List<vehilcle> GetVehicles' is a copy/paste of the documentation of that webservice.

Re: SOAP WebService

PostPosted: Mon Mar 17, 2014 9:29 pm
by James Bott
Marc,

I will try it. vehilcle is not misspelled. 'List<vehilcle> GetVehicles' is a copy/paste of the documentation of that webservice.


Yes, I noticed they misspelled it also. It appears to just be a variable name (which can be anything) and if it were me and I intentionally misspelled it, then later I would spell it correctly somewhere else in the code and then wonder why it was erroring out. Just thought I would mention it.

James

Re: SOAP WebService

PostPosted: Thu Mar 20, 2014 12:57 pm
by Marc Vanzegbroeck
Hi,

It seems stat I only have a problem with receiving arrays.
If a call a method that returns a INT, i receive it without problems.

If the methode returns this, I have an object.
List<vehilcle> = List of vehicles

If the methode returns this, I have a value.
int? = Driver id

Does anyone know how to read an array?

Re: SOAP WebService

PostPosted: Thu Mar 20, 2014 2:05 pm
by James Bott
Marc,

Maybe you can convert it to an XML document?

Code: Select all  Expand view
List<vehilcle> = List of vehicles
oXml := TXmlDocument():New( vehilcle )
xbrowse( oXml )


James

Re: SOAP WebService

PostPosted: Thu Mar 20, 2014 3:04 pm
by James Bott
This is from the Microsoft article on SOAP:

"SOAP is a specification that defines the XML format for messages—and that's about it for the required parts of the spec."


XML Web Services Basics
http://msdn.microsoft.com/en-us/library/ms996507.aspx


James