I am trying to change the value of the parameter in IParameterInspector while doing the validation. The parameters that are string, works fine. But I need int as parameters. and if the parameter is not supplied in the RESTful call, I need to default it.
If the url does not contain anything for int parameter, it fails. However, in the same case of string parameter, if its not supplied, it takes the default values.
I use querystring format for passing the parameters. and I am just trying to run it on the browser.
Is there any way for this to work? or do I need to make all the parameters as string.
Thanks in Advance!
You need to make the parameters string. This will be fixed in the next version of the WCF Web APIS http://wcf.codeplex.com
Related
I have a wcf service having the following operation:
public NewPCNResponse CreateNewPcnExtended(NewPcnExtendedData newPcnExtendedData, string chargeBand, string deviceId, decimal? usageCharge, string plateType)
Note the camel cased parameter chargeBand. The problem is with all the camel cased parameters but I am taking this one for demonstration.
I am using SoapUi to test the calls and the following is the relevant part of the SOAP request:
The element is camel cased and even though it is nullable, it comes thorough as an empty string as shown in the following screenshot:
this fails the validation which I have down the line.
However if the argument is pascal cased, it comes through fine
The easier solution for me to change the casing but I want to know the reason behind this odd behaviour and if I want to keep the argument camel cased what option do I have.
I am writing a hive UDF in which I have to call an REST API and return an array of String. I have written the function with hardcoded REST API url. But now to make the endpoint configurable I want to take the host property out and put it in a config. Is it possible? If yes, then how can pass this?
Can you do change your UDF to take the host as part of its input, and then use variable substitution in Hive:
SET host=todayshosturl
SELECT TRANSFORM ${hiveconf:host}, line
USING 'python myudf.py' AS (line)
FROM
yourtable;
For instance, when to use
GetterUtil.getBoolean()
and when
ParamUtil.getBoolean()?
Are both same, or is it expected to be used differently according to a parameter, a variable, etc? Can you give some examples for both?
Both are util methods to avoid Null-Pointer Exceptions.
GetterUtil internally returns the default type and does the casting too. So in case where someone has passed a null value, it will return default value of the type.
Example:
Assume you have a String value "true", and you are expecting it will always be of type boolean. So you use GetterUtil.getBoolean("true") which will internally do the casting to boolen and return the value as boolean-true. Incase someone passes rubbish characters like "tr", it will be converted to boolean-false.
As mentioned ParamUtil does the same treatment with request parameters. ParamUtil internally uses the GetterUtil to have the above behaviour. It first retrieves the parameter (which always would be a string) and then passes it to GetterUtil.getType() method and in turn returns the proper type.
GetterUtil and ParmUtil both are different classes.
GetterUtil is to get the default values for basic Java data types.
ParamUtil is to retrive the values(of primitive data types) from the HttpReqeust.
Check the source code here for these two classes here
For GetterUtil
http://docs.liferay.com/portal/6.0/javadocs/src-html/com/liferay/portal/kernel/util/GetterUtil.html
For ParamUtil
http://docs.liferay.com/portal/5.1/javadocs/portal-kernel/com/liferay/portal/kernel/util/ParamUtil.java.html
I have a really simple WCF service operation GetCurrentBalance. It returns a decimal.
I also have the odatagen generated entity files included in the project, which contains an implementation of the GetCurrentBalance operation returning a string. Calling this method returns me an XML string with the desired value in it.
I also tried using executeServiceOperation method in the generated class and pass in the operation name as a parameter, the returned value again is the same XML string.
Is there a way to extract this value? Or do I have to write a custom parser for it?
Thanks in advance.
Without further informations, if the returned value is a formatted XML string you may try extracting the value using XPath queries, have a look at this to get you started
It seems there is restriction in having the number of out parameters in WCF. My service reference only downloads one out parameter.
Example: if the service has the following method:
void methodA(out string param1, out string param2)
then the service reference will only create
methodA(out string param1).
Anyone knows how to solve this?
I don't believe there's a limit to the number of out-parameters.
However, for a method that returns void, the first out-parameter actually becomes the return value of the method in the service reference due to a limitation in WSDL. So I would expect the signature of the method to become string methodA(out string param2).
Not sure of a correct fix, but I would return a list of items and not use out parameters in this situation.