NetTalk Central

Author Topic: SOAPserver to return just one value  (Read 5304 times)

Wolfgang Orth

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
    • oData Wolfgang Orth
SOAPserver to return just one value
« on: May 28, 2015, 12:46:54 PM »
Hello Bruce and others,

I want my SOAP-Server to return one value. This is what I get back into the Client and it looks fine:

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...>
<soap:Body>
    <getAnmeldemethode_Response xmlns="">
      <Anmeldemethode>1</Anmeldemethode>
    </getAnmeldemethode_Response>
  </soap:Body>
</soap:Envelope>


How do I get that single value of "Anmeldemethode" into a variable of the Client?

All I see is xml.LOAD( FILE / QUEUE / GROUP, ....).

In my case its just a plain variable.

What I already tried was to make a GROUP with one component. That component is "Anmeldemethode", Apparently I made that wrong. >:(

MyGroup       GROUP,PRE(MyG)
Anmeldemethode    STRING(1)  !1 = Automatisch oder 2 = mit Passwort
                END

In .PageReceived I have this:

xml.Load(MyGroup, WebClient.page, WebClient.pagelen, 'getAnmeldemethode_Response', 'Anmeldemethode')

MyG:Anmeldemethode  should hold a 1 now, but does not, of course.

Thanks in advance,
Wolfgang



« Last Edit: May 28, 2015, 01:04:34 PM by Wolfgang Orth »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: SOAPserver to return just one value
« Reply #1 on: May 28, 2015, 10:29:12 PM »
If you just wanted to return one value then I'd just use a StringTheory.Between method;
This in the client, in .PageRecieved;

str.SetValue(self.page,st:clip)
Anmeldemethode = str.Between('<Anmeldemethode>','</Anmeldemethode>')

Cheers
Bruce

Wolfgang Orth

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
    • oData Wolfgang Orth
Re: SOAPserver to return just one value
« Reply #2 on: May 28, 2015, 10:38:15 PM »
Oh yes, that should do it! I did not see this solution last nicht, was too close. <g>

Thanks, Bruce!

Now I need to find out, why passing the GROUP did not work..... just for the next time when I need that.


peterH

  • Sr. Member
  • ****
  • Posts: 413
    • View Profile
Re: SOAPserver to return just one value
« Reply #3 on: May 29, 2015, 11:51:20 PM »
Hi Wolfgang,
I think it's your file and record  boundaries. It can be a bit tricky to get them right.

Peter

Wolfgang Orth

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
    • oData Wolfgang Orth
Re: SOAPserver to return just one value
« Reply #4 on: May 30, 2015, 12:11:04 AM »
Yes, Peter, I struggle each time with that bounderies. In this case I have hoped that I had copied the right snippet.

OTOH, how boring life would be, if ecerything would work at the first attempt.......

peterH

  • Sr. Member
  • ****
  • Posts: 413
    • View Profile
Re: SOAPserver to return just one value
« Reply #5 on: May 30, 2015, 05:59:07 AM »
I didn't have access to Clarion in my last response, now I do.

There are two problems with your example: 1) you cannot use <getAnmeldemethode_Response xmlns=""> as a boundary because it doesn't have a closing tag that matches (because of the xmlns= thing). 2) don't use Anmeldemethode as boundary either since that's a field in your group.

Since you're in control of the server as well, I'll suggest that you wrap your answer in a label (set file boundary) so that the file will look like this (without the SOAP part):

 <getAnmeldemethode_Response xmlns="">
   <Antwort>
     <Anmeldemethode>1</Anmeldemethode>
   </Antwort>
 </getAnmeldemethode_Response>

Your group definition is fine as it is and the following line of code will load your field:

xml.Load(MyGroup,self.page,len(clip(self.page)),'Antwort','')

Peter



Wolfgang Orth

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
    • oData Wolfgang Orth
Re: SOAPserver to return just one value
« Reply #6 on: May 30, 2015, 06:05:49 AM »
> I'll suggest that you wrap your answer in a label (set file boundary)

That makes sense, Peter!

I will try that soon.

Right now I struggle with UPPERCASE in the XML-tags.

Yesterday it worked all fine. Today I continued on another part of the App and all is broken.

I really wonder who altered my code over night........  ;D

Thanks for the explanation!


peterH

  • Sr. Member
  • ****
  • Posts: 413
    • View Profile
Re: SOAPserver to return just one value
« Reply #7 on: May 30, 2015, 06:10:09 AM »
xml.TagCase = XF:CaseAny

Wolfgang Orth

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
    • oData Wolfgang Orth
Re: SOAPserver to return just one value
« Reply #8 on: May 30, 2015, 06:21:29 AM »
> xml.TagCase = XF:CaseAny

That one is gracefully ignored by my App.   ::)

However, there is also a good chance that I overlook something important. Maybe I delved too deep and need some distance now.

OTOH I need to continue and do some progress. <yadda-yadda>

;-)