on 09-15-2015 4:13 PM
Windows Clients: Windows 7 and 8.0
Powerbuilder Classic 12.5.2 Build 5583
Visual Studio 2013, .NET 4.5, C# WCF web services
Can anyone point me to how to code the web services side of things so I can return a validation error from web services (we are using C# .NET 4.5 WCF for Web Services) to a web services datawindow .Update statement. Ideally I'd like .Update to return -1 and not update the datawindow row statuses if there was a validation error.
The reason I am asking is this:
I have a web services datawindow, it retrieves and updates wonderfully. Now I add some logic in the web services to validate the incoming data. If some data is invalid I want the update to fail and the user to see a message.
To handle the above scenario I am calling a SOAP Fault in the web services and returning a nice message. Catching it in WSError and handling it in a nice manner. All seemed fine EXCEPT, after I get the error message I fix the problem in the data by setting another column from, for example, A to null, because that would then make the first column valid. What then happens is if I look at the primary buffer of the datawindow just before the .Update is called is has null in it as expected, but if I look at the XML incoming to the web services it has A in it!!!! This only seems to happen if a SOAP Fault was thrown first. Otherwise null is sent as expected.
I have checked, all columns are marked as nullable in both the datawindow definition and the web services, and the datatypes in the web services are nullable datatypes. Saving with null works just fine as longs as, I think, an exception wasn't thrown already. It only seems to be a problem with nulls.
So it has left me with a number of pressing questions:
1. Am I just handling validation wrong, and should not be throwing a SOAP fault? If so, what is the normal way of handling these things?
2. Is this a bug in PB (installing 12.6 + latest EBF as I type)
3. Am I going even more crazy than I already was before I started this project?
If anyone has any input / ideas it would be welcome. Thank you.
Hi Aron;
FWIW: I only send back a completion code to the client +1 = OK and -1, -2, ... if an error has occurred. I let the client handle the error text as in Canada we have to be multilingual with our error text back to the user in their current language. Also, the client application can decide on how to format the text for the appropriate device (C/s, Web Browser, mobile, etc) given space and linguistic challenges.
HTH
Regards ... Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Chris, we are handling the multi-language stuff on the server, asking them to pass us their required language, as well as returning error numbers in case the client wants to do something different, but there's still a way to go before it's all working
So how are you passing back that completion code? Are you using web services datawindows, or calling them via the proxy?
If you're using datawindows are you throwing faults / exceptions or returning ref variables / columns?
Thanks!
P.S. Just got back from Vancouver, Canada - made me yearn for the days when I lived there instead of the UK
I just return an INT - which is basically a return code + your OK and - values for Oh, Oh <bg>!.
I guess I could also return a negative message message number ... for example -123 - then drop the sign and go after Message #123 in a common message DB table that both the client, SP's and WS's use. (food for thought).
Okay, I guess that means you aren't using web services datawindows then as as far as I can tell no return values are used. In fact I decompiled the dll that was created by Powerbuilder from the web services WSDL and it looks like VOID is returned from an Update, so I'm never going to get -1.
I figured since I was doing retrieves and updates using web services datawindows would be the best way to go.
Okay, So how do you get a return code back from a WS DW on an Update? I tried and it wouldn't work. I can get whatever I want on a retrieve but not on an Update.
As far as I can tell (and I'm probably totally wrong) the only things I can do on a WS DW Update is throw an exception and catch it in WSError or use ref variables / columns and look at them after the Update???
Hi Aron;
FYI: here is some code that I use in my example OrderEntry application from the STD Integrated & Web Service frameworks ...
IF go_ac.of_get_client_type ( ) = "PB" THEN // Native App?
SQLCA.of_connect ( ) // YES=>Try 2 Connect!
else
// Must be Appeon Web or Mobile - so use a Web Service!.
ns_ds_webservice_master lo_ds
Long ll_rows
lo_ds = CREATE ns_ds_webservice_master
lo_ds.dataobject = "dw_login_validate"
lo_ds.of_set_ws_dw_section_name ( "OES_Login") // Set security
il_rc = lo_ds.Retrieve ( SQLCA.DBParm )
IF il_rc = 1 THEN // Got a RS?
SQLCA.sqlcode = lo_ds.GetItemNumber (1, &
"ReturnValue") // YES=> Get WS RC
IF SQLCA.SQLCode = 0 THEN //OK?
SQLCA.of_connect ( ) // YES=Do real Connect!
ELSE
SQLCA.sqldbcode = -103 // NO=>Set Reason
END IF
else
SQLCA.sqlcode = FAIL // NO=> Fail
SQLCA.sqldbcode = -103 // Set Reason
END IF
END IF
HTH
Regards ... Chris
Thanks Chris, looks like you're doing a retrieve there rather than an update, so you get back some data into the datawindow. Unfortunately I want to validate the data as it's being updated, so I'm putting the validation just before the update statement in the web services, in the web service method that is called by update. So I have to deal with what the WS DW can return for an Update which appears to be not a lot (or a lot, but in possibly a buggy way).
Thanks Chris, I guess you went for the retrieve as it can return data. I am converting an existing application so I figured mapping the retrieve to a WS retrieve, and update to a WS update, delete, insert etc, would make sense as all my existing code after that could stay the same. Seems like I need to either see if this has been fixed in a later version; use retrieve like you do; or return errors using reference variables instead. Some thinking to do, if only I'd found this issue about a year ago when I started the project, and one three days before the release to testing!
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.