Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: webservice call working standalone but not in project

$
0
0
Re: webservice call working standalone but not in project
Web Service Proxy Generator
Re: webservice call working standalone but not in project
Jan. 13, 2013
09:57 am
3OW0LCTWMShow this entire thread in new window
Gratar Image based on email address
From:Rick Strahl
To:Frits van den Munckhof
Are you checking the values that are being passed to this method and can you verify the right values are making it into the method? Is the code really identical? And more importantly are the types of the values the same? In the second example you're reading values from input fields directly which might cause further type conversion issues. I'd assign those values to variables and then run the debugger to check the variables explicitly.

The error message you see is in dutch because it comes from .NET which will return the error message in the local machine's culture context which on your machine is dutch.

Another thing that could be a problem is the type of the number. FoxPro numbers pass through as double values. What's the type of the numeric value expected? You might have to cast the value explicitly or use the ComValue() potentially. IOW, assigning the value to a variable and pass that then CAST(lnValue as integer) or whatever is needed.

Sometimes it can also help to call oBridge.InvokeMethod() instead of calling the method directly as wwDotnetBridge does some automatic fixups for some problematic values and conversions. Doesn't always help, but it can.

+++ Rick ---


Hi Rick,

Perhaps you can help me out. I'm making an app to consume a webservice for creditmanagement, using your Web Service Proxy generator. I constructed a proxy with the generator: authoriserproxy.prg. I placed this prg with the other depending prgs/dlls in a new folder authoriserproxy of my main project folder. There are 2 relevant methods: getsaldo and purchase. The getsaldo ("saldo"=balance) method works fine using this code:

(form.init)*** Load the Proxy and Support Class LibrariesDO AuthoriserProxy.prg*** Create an instance of the Proxy THISFORM.Authoriser = CREATEOBJECT("AuthoriserProxy") && Optionally specify .NET Version (form.getcard-method - simplified)LOCAL llResult, lnSaldo, lnTransactieID, lnResultCode, lcResultDescription llResult=.F. lnSaldo=0 * Saldo ophalen *** Downloads an object - GetCardData itemLOCAL loItem as GetCardData, lcTransact lcTransact=GETKEY("Transact") loItem = THISFORM.Authoriser.GetCard(THISFORM.CardType,THISFORM.Requestor,THISFORM.ClientID,THISFORM.ClientPassword,; TRIMSTR(OBJ_NUM(lcTransact)),THISFORM.ClientReference,THISFORM.Pages.Transacties.txtNummer.Value,"",THISFORM.MsgVersion)*** Check for Errors if necessaryIF THISFORM.Authoriser.lError THISFORM.Melding("Saldo opvragen mislukt:"+CR+THISFORM.Authoriser.cErrorMsg,"Rood",0)ELSE lnTransactieID=THISFORM.Authoriser.oBRIDGE.getproperty(loitem,"transactionid") lnResultCode=loItem.ResultCode lcResultDescription=loitem.ResultDescriptionIF lnResultCode=0 && Succes lnSaldo=THISFORM.Authoriser.oBRIDGE.getproperty(loitem,"balance")/100 llResult=.T.ELSE THISFORM.Melding("Foutmelding "+TRIMSTR(lnResultCode),"Rood",0) ENDIF THISFORM.Saldo=lnSaldo RETURN llResult

As said above code works as expected. So I figured that calling the other method would be simple.

(form.purchase-method - simplified)LOCAL llResult, lnSaldo, lnTransactieID, lnResultCode, lcResultDescription, lnWaarde, loService lnWaarde=VAL(THISFORM.Pages.Transacties.txtWaarde.Value)*100 loService=THISFORM.Authoriser llResult=.F. lnSaldo=THISFORM.Saldo *** Downloads an object - PurchaseData itemLOCAL loItem as PurchaseData, lcTransact lcTransact=GETKEY("Transact") loItem = loService.purchase(THISFORM.CardType,THISFORM.Requestor,THISFORM.ClientID,THISFORM.ClientPassword,; TRIMSTR(OBJ_NUM(lcTransact)),THISFORM.ClientReference,THISFORM.Pages.Transacties.txtNummer.Value,"",; lnWaarde,THISFORM.MsgVersion)*** Check for Errors if necessaryIF loService.lError THISFORM.Melding("Afwaarderen mislukt:"+CR+loService.cErrorMsg,"Rood",0) ELSE lnTransactieID=loService.oBRIDGE.getproperty(loitem,"transactionid") lnResultCode=loItem.ResultCode lcResultDescription=loitem.ResultDescriptionIF lnResultCode=0 && Succes lnSaldo=loService.oBRIDGE.getproperty(loitem,"cardnewbalance")/100 llResult=.T.ELSE THISFORM.Melding("Afwaarderen, foutmelding "+TRIMSTR(lnResultCode),"Rood",0) ENDIFENDIF THISFORM.Saldo=lnSaldo RETURN llResult

For the purchase-call however loService.lError returned .T. AND loService.cErrorMsg returned "Methode Authoriser.Authoriser.Purchase is niet gevonden..." (=Method .... not found). I then set a breakpoint to inspect the loService-object and intellisense showed its Purchase-method. So I tried typing the purchase-call directly from the command window and the webservice was called correctly. But after continuing and tracing the loService.purchase()-call in the above code the "invokemethod"-call generated the error I mentioned. strange: what's different from calling it from the Command-window in debug-mode?

And where is this dutch errormsg coming from?

I finally wrote a standalone prg to test the purchase call

(standalone purchase.prg)LPARAMETERS lnValue* SET PATH TO ".\AuthoriserProxy" ADDITIVEDO AuthoriserProxy.prgLOCAL loService, loItem, lnSaldo loService=CREATEOBJECT("AuthoriserProxy") && Optionally specify .NET Version loItem = loService.purchase("THECARD","IKKE","MYFIRM","123456",;"Transact1","FM","1234567890123456789","", lnValue*100,"POS")*** Check for Errors if necessaryIF loService.lError AppMsg("Afwaarderen mislukt:"+CR+loService.cErrorMsg,"Mislukt","X")ELSE lnTransactieID=loService.oBRIDGE.getproperty(loitem,"transactionid") lnResultCode=loItem.ResultCode lcResultDescription=loitem.ResultDescriptionIF lnResultCode=0 && Succes lnSaldo=loService.oBRIDGE.getproperty(loitem,"cardnewbalance")/100 llResult=.T. AppMsg("Nieuw saldo:"+TRIMSTR(lnSaldo),"Geslaagd","I")ELSE AppMsg("Afwaarderen, foutmelding "+TRIMSTR(lnResultCode)),"Mislukt","X")ENDIFENDIF

When I call this program from the Command-window with the command

DO purchase WITH 1

everything works fine.

But when I put it in the click()-code of a form-button like:

Purchase(lnWaarde)

oBridge.Invokemethod again generates the dutch error message.

Any idea what is causing this behaviour?


Viewing all articles
Browse latest Browse all 10393

Trending Articles