NetTalk Central

Author Topic: Nettalk Webservice with Windev Mobile  (Read 4367 times)

Neil Porter

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Nettalk Webservice with Windev Mobile
« on: September 10, 2012, 01:00:16 AM »
I thought I posted this question on here a while back, but as neither myself or Bruce can find it now, maybe I'm just losing the plot....appologies if this is a duplicate.

Bruce has kindly replied directly, but I thought I'd post my original question, and his response (in green) on here in case someone else was trying to do something similar:-

Quote
If you remember, when we last met I was trying to use a Nettalk Webserver to extend one of my existing products so that I could capture barcodes on a mobile device. I couldn’t really get it to do what I wanted, so I’ve been looking at other development tools. There seems to be a lot of hype at the moment on the Clarion forums about WinDev, so I’ve jumped on the band wagon and had a look at Windev Mobile. On the face of it, it looks quite promising, but the real crux of it for me in the transferring of data between my main applications SQL server database, and the mobile applications.
 
PCSoft also produce a product called Webdev. You design your webservice in Webdev, and publish it using IIS or Apache, and the Webdev application server. This webservice than talks to my sql database, and sends the data that I require to my mobile device. This also creates you a nice .wsdl document that you can then import into WinDev Mobile which allows you to post requests from the mobile device, and retrieve data from the webservice.
 
I already use Nettalk as a soap server, and I’m looking at the Windev scenario thinking that maybe I could use Nettalk as my webservice, and do away with IIS/Apache and the Webdev Application server.

yes, good idea.
 
Quote
There doesn’t seem to be a way that I can post requests from Windev Mobile without a wsdl file to import, so I manually created one that I hoped would allow me to test my theory with an existing Nettalk Soap server that I have running.

yes, good idea.
 
Quote
At the moment, I’m using Fiddler2 to monitor what is being posted to, and received from my server, and I’m using SoapUI to create test posts using my wsdl definition file. I’m comparing this with what my existing Clarion client application posts using nettalk so that I can try to see if this is going to work without even bring windev into the equation yet.
 
I’ve come across a couple of problems, that I’d like your input on if you’d be so kind.
 
My current Clarion client application creates the following Soap Post:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<data>
  <group>
    <PROGRAMNAME>Indigo</PROGRAMNAME>
    <COMPANYNAME>Neil Porter Associates Ltd</COMPANYNAME>
    <VERSIONNO>4.1.1.72</VERSIONNO>
    <WEBBOOKINGS>500</WEBBOOKINGS>
    <EXPIRES>31/12/2012</EXPIRES>
    <COPIES>10</COPIES>
  </group>
</data>
</soap:Body>
</soap:Envelope>
 
Which gets the following response:
<?xml version="1.0" encoding="ISO-8859-1"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<data>
  <group>
    <ROLE>Error</ROLE>
    <ERRORCODE>0</ERRORCODE>
    <ERRORSTRING>Success</ERRORSTRING>
  </group>
</data>
</soap:Body>
</soap:Envelope>
This very simple and works great.
 
I’ve tried to replicate this by creating the attached basic.wsdl file. Using Soap UI this creates the following post:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:DevSoap">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:UpdateInfo>
         <ProgramName>?</ProgramName>
         <CompanyName>?</CompanyName>
         <VersionNo>?</VersionNo>
         <WebBookings>?</WebBookings>
         <Expires>?</Expires>
         <Copies>?</Copies>
      </urn:UpdateInfo>
   </soapenv:Body>
</soapenv:Envelope>
I’ve highlighted some parts in red. These are the bits that worry me in particular.

none of these are a problem (I presume you're using xFiles?). The urn:UpdateInfo is just a group wrapper – literally if you just put a group inside your current clarion group that will take care of that.
 
Note though that the tags are case sensitive – so you can use External Names, (and xml.tagCase = xf:CaseAny) on the clarion side, or get the case in the WSDL to all uppercase for the field names, or whatever.

 
Quote
My procedure that I’m looking to call in my nettalk soap server is called UpdateInfo, and I post to http://www.neilporterassociates.org.uk:99/UpdateInfo from my client application. In Windev it looks like I need to post to http://www.neilporterassociates.org.uk:99 and then I need to specifiy the urn to tell it what procedure should be called by the webserver. Do you think that I would be best to create a generic procedure in my Nettalk server (called ReceiveRequests for example) that will parse the soap request, look at the urn value, and then decide what to do with the rest of the request, or do I have some other simpler option?

So you might be getting ahead of yourself slightly here.
I might do it in this order;
 
a) make a WDSL doc the way "you want it". I'm not sure how complicated this will be, but I don't _think_ it's terribly complicated. As you note there are a number of approaches with regard to the URLS, but I'd just do whatever makes the WSDL easiest.
 
b) make the Windev mobile program based on the doc, and run that against a plain Nt server.
You'll be able to see the incoming requests, so if you need to you can adapt your server to what the Mobile is asking.
Or, tweak the WSDL, rinse and repeat. Obviously keep this cycle as simple as possible till you have the basic framework of what you need.
 
c) Flesh out the server to actually "do stuff" with what the mobile is sending you.
 
I'm guessing this is one of those cases where small steps make for fast progress.

 
Quote
I’ve also been comparing these requests with ones generated using Windev Mobile and the Webdev Application server:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Indigo">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:gpUserLogin>
         <psUserName>?</psUserName>
         <psPassword>?</psPassword>
      </urn:gpUserLogin>
   </soapenv:Body>
</soapenv:Envelope>
 
<SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Body>
      <ns1:gpUserLoginResponse xmlns:ns1="urn:Indigo">
         <gpUserLoginResult><![CDATA[<?xml version="1.0" encoding="ISO-8859-1"?>
<Logon><Result>Username unrecognized</Result><Code>2</Code><UserCode/></Logon>]]></gpUserLoginResult>

      </ns1:gpUserLoginResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I noticed that I seem to be receiving xml within xml with a CDATA prefix. Does this have any significance do you think?

so this is fairly common. You have a field in this case, gpUserLoginResult, which itself is just a string – but that string happens to contain xml stuff. so as not to confuse the xml packet itself, strings are allows to be "encoded" as CDATA. (xFiles has this as an option – you can encode all strings as CDATA, or just some of them.) the trick is to "see" the UserLoginResult here as "just a string. 
 
Quote

I’m hoping that this is probably just the way that windev mobile is expecting to receive it’s response, so I can format it similarly in my NT webserver.
If I can I’d realy like to use a Nettalk webserver, and with my limited experience it looks like it should be possible, but I don’t want to spend weeks banging my head against a brick wall, if it’s never going to work. I suppose what I’m after from you, is an answer as to whether I’m trying to make Nettalk do something that it realy wasn’t designed to do.

On the contrary, you're using it to do something it was explicitly designed to do. Should be no problems.
 



Clarion 11.0.13244
NetTalk 11.04