PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WEBDEV 2024 → Return Multiple Results from Service
Return Multiple Results from Service
Iniciado por Mister RUAN, 27,jul. 2017 12:53 - 4 respuestas
Miembro registrado
208 mensajes
Popularité : +1 (1 vote)
Publicado el 27,julio 2017 - 12:53
Good Day

I created a web service on WebDev. First I declared a structure:

STGetCurrentPrice is structure
bSuccess is boolean
sErrorMessage is string
sProductCode is string
sProductDescription is string
cyPrice is currency
nProductID is int
END


Then i created a Procedure:

Procedure getCurrentPrice(sProductCode)

stThisresult is STGetCurrentPrice

FOR EACH Service_Product_Test WHERE Service_Product_Test.ProductCode = sProductCode
stThisresult.bSuccess = True
stThisresult.sProductCode = Service_Product_Test.ProductCode
stThisresult.sProductDescription = Service_Product_Test.ProductDescription
stThisresult.cyPrice = Service_Product_Test.Price
END
RESULT stThisresult


It Works great but It only returns a single result and not multiple results.

I have 2 Items in my database with ItemCode "AAA" but it only returns 1

I have this test Procedure that returns result:

Procedure TestGetCurrentPrice()

sDisplayResult is string = [
bSuccess = %1
sErrorMessage = %2
sProductCode = %3
sProductDescription = %4
cyPrice = %5
]

stTheresult is ServerProcedures.STGetCurrentPrice


stTheresult = ServerProcedures.getCurrentPrice("AAA")
InfoBuild("Good Code"+CR+sDisplayResult,stTheresult.bSuccess,stTheresult.sErrorMessage,stTheresult.sProductCode,stTheresult.sProductDescription,stTheresult.cyPrice)


How can I get a result that return both lines at the same time?

Regards

Ruan
Publicado el 27,julio 2017 - 14:35
Hi

how could you get multiple results when your code is settings all the
found values into ONE variable only?

You need an array to do something like that, or you can also set all
yours values one after another in a string or a buffer, but what you do
currently is simply replacing one value by th next in your variable0

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com

Le 7/27/2017 à 4:53 AM, Mister RUAN a écrit :
Good Day

I created a web service on WebDev. First I declared a structure:

STGetCurrentPrice is Structure
bSuccess is boolean
sErrorMessage is string
sProductCode is string
sProductDescription is string
cyPrice is currency
nProductID is int
END


Then i created a Procedure:

PROCEDURE getCurrentPrice(sProductCode)

stThisresult is STGetCurrentPrice

FOR EACH Service_Product_Test WHERE Service_Product_Test.ProductCode =
sProductCode
stThisresult.bSuccess = True
stThisresult.sProductCode = Service_Product_Test.ProductCode
stThisresult.sProductDescription =
Service_Product_Test.ProductDescription
stThisresult.cyPrice = Service_Product_Test.Price
END
RESULT stThisresult


It Works great but It only returns a single result and not multiple
results.

I have 2 Items in my database with ItemCode "AAA" but it only returns 1

I have this test Procedure that returns result:

PROCEDURE TestGetCurrentPrice()

sDisplayResult is string = [
bSuccess = %1
sErrorMessage = %2
sProductCode = %3
sProductDescription = %4
cyPrice = %5
]

stTheresult is ServerProcedures.STGetCurrentPrice


stTheresult = ServerProcedures.getCurrentPrice("AAA")
InfoBuild("Good
Code"+CR+sDisplayResult,stTheresult.bSuccess,stTheresult.sErrorMessage,stTheresult.sProductCode,stTheresult.sProductDescription,stTheresult.cyPrice)


How can I get a result that return both lines at the same time?

Regards

Ruan
Miembro registrado
208 mensajes
Popularité : +1 (1 vote)
Publicado el 27,julio 2017 - 15:05
Fabrice Harari wrote:
Hi

how could you get multiple results when your code is settings all the
found values into ONE variable only?

You need an array to do something like that, or you can also set all
yours values one after another in a string or a buffer, but what you do
currently is simply replacing one value by th next in your variable0

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com

Le 7/27/2017 à 4:53 AM, Mister RUAN a écrit :
Good Day

I created a web service on WebDev. First I declared a structure:

STGetCurrentPrice is Structure
bSuccess is boolean
sErrorMessage is string
sProductCode is string
sProductDescription is string
cyPrice is currency
nProductID is int
END


Then i created a Procedure:

PROCEDURE getCurrentPrice(sProductCode)

stThisresult is STGetCurrentPrice

FOR EACH Service_Product_Test WHERE Service_Product_Test.ProductCode =
sProductCode
stThisresult.bSuccess = True
stThisresult.sProductCode = Service_Product_Test.ProductCode
stThisresult.sProductDescription =
Service_Product_Test.ProductDescription
stThisresult.cyPrice = Service_Product_Test.Price
END
RESULT stThisresult


It Works great but It only returns a single result and not multiple
results.

I have 2 Items in my database with ItemCode "AAA" but it only returns 1

I have this test Procedure that returns result:

PROCEDURE TestGetCurrentPrice()

sDisplayResult is string = [
bSuccess = %1
sErrorMessage = %2
sProductCode = %3
sProductDescription = %4
cyPrice = %5
]

stTheresult is ServerProcedures.STGetCurrentPrice


stTheresult = ServerProcedures.getCurrentPrice("AAA")
InfoBuild("Good
Code"+CR+sDisplayResult,stTheresult.bSuccess,stTheresult.sErrorMessage,stTheresult.sProductCode,stTheresult.sProductDescription,stTheresult.cyPrice)


How can I get a result that return both lines at the same time?

Regards

Ruan


Hi Fabrice

I did create an array but keep getting errors when returning result. If possible do you have an example of a working service that returns multiple items in a result.

Thanks

Ruan
Publicado el 27,julio 2017 - 15:26
Hi Ruan,

I did create an array but keep getting errors when returning result. If
possible do you have an example of a working service that returns
multiple items in a result.


Yes I do... It's a REST webservice used in WXReplication to send and
receive datasets...

So everything is available on my web site in the open source section.
In this one, I'm writing all the information in a string before sendind
the string.

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com


Thanks

Ruan
Miembro registrado
208 mensajes
Popularité : +1 (1 vote)
Publicado el 28,julio 2017 - 12:15
Fabrice Harari wrote:
Hi Ruan,

I did create an array but keep getting errors when returning result. If
possible do you have an example of a working service that returns
multiple items in a result.


Yes I do... It's a REST webservice used in WXReplication to send and
receive datasets...

So everything is available on my web site in the open source section.
In this one, I'm writing all the information in a string before sendind
the string.

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com


Thanks

Ruan


Hi Fabrice

I managed to get this right doing this:

Procedure Test5(sProductCode)

stThisresult is STGetCurrentPrice
arrKeywords is array of STGetCurrentPrice

FOR EACH Service_Product_Test WHERE Service_Product_Test.ProductCode = sProductCode
stThisresult.bSuccess = True
stThisresult.sProductCode = Service_Product_Test.ProductCode
stThisresult.sProductDescription = Service_Product_Test.ProductDescription
stThisresult.cyPrice = Service_Product_Test.Price

ArrayAdd(arrKeywords,stThisresult)

END

RESULT arrKeywords


Getting this response:

<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:Header/>
<SOAP-ENV:Body>
<ns1:Test5Response xmlns:ns1="urn:ciacloud_service">
<Test5Result>
<bSuccess>True</bSuccess>
<sErrorMessage/>
<sProductCode>AAA</sProductCode>
<sProductDescription>Apple</sProductDescription>
<cyPrice>50</cyPrice>
<nProductID>0</nProductID>
</Test5Result>
<Test5Result>
<bSuccess>True</bSuccess>
<sErrorMessage/>
<sProductCode>AAA</sProductCode>
<sProductDescription>Boat</sProductDescription>
<cyPrice>12500</cyPrice>
<nProductID>0</nProductID>
</Test5Result>
</ns1:Test5Response>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


But left me now with new challenge. I call this from my Windev Mobile but cannot get the results into my table. Worked through your example as well but couldn't find anything that will help me. How do I get this structure into my table or database on the phone?

Regards

Ruan