IN clause usage in WSO2 DSS - wso2

I'm facing wso2 data service problem with simple query.
Expected query:
I want to use IN clause with multiple value. This is my sample query:
SELECT ORGANIZATION_ID, ORGANIZATION_NAME FROM ORGANIZATION WHERE ORGANIZATION_ID IN (?)
ORDER BY ORGANIZATION_NAME ASC
Getting error:
When i try web service using "1,2,3" value, i get javax.xml.stream.XMLStreamException error.
How can i write above query in WSO2 DSS?
Please advice me on that.
Thanks,
Eba

Refer the following data service query configuration which contains a sample input parameter of type "ARRAY" which you can effectively use to get your requirement fulfilled.
<query id="setSalaryForEmployeesQuery" useConfig="default">
<sql>update Employees set salary=:salary where employeeNumber in (:employeeNumbers)</sql>
<param name="salary" ordinal="1" paramType="SCALAR" sqlType="DOUBLE" type="IN"/>
<param name="employeeNumbers" ordinal="2" paramType="ARRAY" sqlType="INTEGER" type="IN"/>
</query>
There, if you refer the input mapping configuration named "employeeNumbers", it basically addresses the same requirement mentioned in your query.
To try this functionality, you can use the "tryIt" functionality provided with each data service(similar to other service types) and the data service request format corresponding to the aforementioned configuration would look like what's depicted below.
<p:setSalaryForEmployees xmlns:p="http://ws.wso2.org/dataservice/samples/rdbms_sample">
<!--Exactly 1 occurrence-->
<xs:salary xmlns:xs="http://ws.wso2.org/dataservice/samples/rdbms_sample">1000</xs:salary>
<!--1 or more occurrences-->
<xs:employeeNumbers xmlns:xs="http://ws.wso2.org/dataservice/samples/rdbms_sample">1011</xs:employeeNumbers>
<xs:employeeNumbers xmlns:xs="http://ws.wso2.org/dataservice/samples/rdbms_sample">1022</xs:employeeNumbers>
</p:setSalaryForEmployees>
The complete data service configuration which contains the above configuration snippet can be located in the "DSS_HOME/sample/dbs/rdbms/RDBMSSample.dbs" which resides in DSS product archive.

Related

Shibboleth SP - NameID attribute map

I am just learning Shibboleth SP and I have run into an issue where I cannot read the NameID from the SAML Response I receive from our corporate IdP. The only "attribute" they have configured for me is the NameID which holds the username in our AD. They do not add it as an attribute, but rather in the subject. Below is the portion of the SAML response containing the NameID.
<Subject>
<NameID>XXXXXX</NameID>
<SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<SubjectConfirmationData InResponseTo="_cbedab7210959e0d00294c557c648eb5"
NotOnOrAfter="2017-05-18T21:15:24.776Z"
Recipient="https://xxxxxx.com/Shibboleth.sso/SAML2/POST"
/>
</SubjectConfirmation>
</Subject>
How can I extract this simple value? I have not found an example entry in the attribute-map.xml that seems to fit the bill.
I am using IIS 8.5 and ColdFusion.
I finally got the attribute to map using the following. In my case, I had replaced SAML:1.1 with SAML2. I assume the NameID is part of the SAML:1.1 spec.
<Attribute name="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" id="NameID">
<AttributeDecoder xsi:type="NameIDAttributeDecoder" formatter="$Name" defaultQualifiers="true"/>
</Attribute>

mule - web service consumer (soap) always returns null

I am using the Zuora soap API. I am attempting to perform a query. I don't get any errors but the results are always null when I output the payload to log. What am I doing wrong? (the query I provide below should return 320 records, which is what I get if I execute the same query in a local non-mule test script)
This is the section of the flow.
I set the zoql query to flowVars (flowVars.query). For example : select id from Account WHERE updatedDate > '2016-06-24T23:00:00-06:00'
I use dataweave to create the xml payload (dw provided below)
I execute the query (web service consumer app xml details provided below)
DataWeave to set payload:
%dw 1.0
%output application/xml
%namespace ns0 http://api.zuora.com/
---
{
ns0#query: {
ns0#queryString: flowVars.query
}
}
Web Service Consumer app xml
<ws:consumer config-ref="ZuoraWebServiceConsumer" operation="query" doc:name="query_zuora"/>
ZuoraWebServiceConsumer config details:
<ws:consumer-config name="ZuoraWebServiceConsumer" wsdlLocation="zuora.a.49.0-sandbox.wsdl" service="ZuoraService" port="Soap" serviceAddress="https://apisandbox-api.zuora.com" doc:name="Web Service Consumer">
<ws:security>
<ws:wss-username-token username="myusername.here" password="mypassword.here" passwordType="TEXT" />
</ws:security>
</ws:consumer-config>
And the WSDL:
https://www.dropbox.com/s/fkrppvv7i5s1a4w/zuora.a.49.0-sandbox.wsdl?dl=0
After working with MuleSoft Support, it was discovered there is a bug with the Zuora connector. When Zuora returns an invalid session error, the Zuora connector is not catching it, destroying the connection from the pool, and initiating a new connection. MuleSoft has confirmed the bug.

How to fetch a tag value from Test step response file (REST request's response) in SOAP UI

I am a newbie to SOAP UI, I need to fetch a tag value from Test step response file (REST request's response) and set it as testsuite property.
My Request file looks like;
<xdata created_by="XXXX" created_at="Wed Mar 16 08:45:39 EDT 2016" app="" profile="" app_version="" env="DEV" tran="" service="1234">
<rows start_index="0">
<row basketId="1234566" basketVersionId="11" basketName="ORDERS_1505" basketDescription="ORDERS" createdUserName="XXXX" updatedUserName="XXX" __errorMsg="{"errors":[],"success":true}" totalApprovedOrderCount="0"/>
</rows>
</xdata>
I need to fetch basketVersionId attribute, please help.
Note: All the examples I read are dealing with Soap Response, property transfer using namespace and xpath. but that is not woking here I guess.
SOAPUI converts practically all to Xml, so despite the fact that you've a REST service you can use anyway and XPath in the property transfer testStep.
The only difference is that in property transfer you've to select:
ResponseAsXml as a property for the REST service with a Json response.
Response as a property for a SOAP service with Xml response.
So you can use: //*:row/#basketVersionId as XPath to get your attribute value.
Hope it helps,

JSON mapping in wso2 siddhi cep

This is to get some clarity on the JSON mapping of the generated JSON events in WSO2 CEP.
I configured two buckets for this. I have a string (Suresh 7 LeadSE) and I'm converting that into a JSON object. First bucket is getting the input string and I have written a siddhi extension to convert this into JSON.
The FirstBucket will get the input as String and converts it into a JSON and put it in a topic called parsedPacketTopic. Now I would like to get the individual elements from this JSON. I am trying to get this through the SecondBuket configuration. However, I don't know how to map the generated JSON value in the SecondBucket.
I am getting null values for the fields expInYears, empName, position and I don't know how exactly to map the generated JSON to these fields.
Can anyone help on this?
Code
FirstBucket configuration
<cep:input brokerName="localAgentBroker" topic="rawPacketTopic/1.0.0">
<cep:tupleMapping queryEventType="Tuple" stream="rawPacketStream">
<cep:property inputDataType="payloadData" inputName="rawPacket"
name="rawPacket" type="java.lang.String"/>
</cep:tupleMapping>
</cep:input>
<cep:query name="Queryfirst">
<cep:expression><![CDATA[from rawPacketStream[rawPacket!="null"]
insert into parsePacketStream customExtn:testFun(rawPacket) as pac]]>
</cep:expression>
<cep:output brokerName="activemqJmsBroker" topic="parsedPacketTopic">
<cep:mapMapping>
<cep:property name="parsedPac" valueOf="pac"/>
</cep:mapMapping>
</cep:output>
</cep:query>
Stream Definition of rawPacketTopic
{"streamId":"rawPacketTopic:1.0.0","name":"rawPacketTopic","version":"1.0.0","nickName":"PVT_Data","description":"PVT_Data","metaData":[{"name":"clientType","type":"STRING"}],"payloadData":[{"name":"rawPacket","type":"STRING"}]}
Stream Definition of parsedPacketTopic
{"streamId":"parsedPacketTopic:1.0.0","name":"parsedPacketTopic","version":"1.0.0","description":"PVTsinJson","metaData":[{"name":"ClientType","type":"STRING"}],"payloadData":[{"name":"parsedPac","type":"STRING"},
{"name":"expInYears","type":"INT"},{"name":"empName","type":"STRING"},{"name":"position","type":"STRING"}]}
i am getting the parsedPac json value as {"expInYears":7,"empName":"Suresh","position":"LeadSE"}
SecondBucket Configuration
<cep:input brokerName="activemqJmsBroker" topic="parsedPacketTopic">
<cep:mapMapping queryEventType="Tuple" stream="parsedPacketStream">
<cep:property inputDataType="payloadData" inputName="parsedPac" name="parsedPac" type="java.lang.String"/>
<cep:property inputDataType="payloadData" inputName="expInYears" name="expInYears" type="java.lang.Integer"/>
<!--<cep:property inputDataType="payloadData" inputName="empName" name="empName" type="java.lang.String"/>
<cep:property inputDataType="payloadData" inputName="position" name="position" type="java.lang.String"/>-->
</cep:mapMapping>
</cep:input>
<cep:query name="SecondQuery">
<cep:expression><![CDATA[from parsedPacketStream[parsedPac !="null"]
insert into displayPacketStream * ]]></cep:expression>
<cep:output brokerName="activemqJmsBroker" topic="displayTopic">
<!--<cep:mapMapping>
<cep:property name="expInYears" valueOf="expInYears"/>
<cep:property name="empName" valueOf="empName"/>
<cep:property name="position" valueOf="position"/>
</cep:mapMapping> -->
<cep:textMapping>Experience is - {expInYears}</cep:textMapping>
</cep:output>
</cep:query>
Stream Definition of displayTopic
{"streamId":"displayTopic:1.0.0","name":"displayTopic","version":"1.0.0","description":"PVTsinJson","metaData":[{"name":"ClientType","type":"STRING"}],
"payloadData":[{"name":"expInYears","type":"INT"},{"name":"empName","type":"STRING"},{"name":"position","type":"STRING"}]}
I think you are attempting JSON mapping which is not directly supported in WSO2 CEP 2.1.0.
If I understood your question correctly, I think you are converting the raw input into JSON from the extension in first cep bucket and then writing the second query based on that. However, since JSON input mapping is not directly supported, the second query will only see the whole string and not a JSON object.
Is there a specific requirement to convert the raw input to JSON in your scenario?
If not, using your custom extension, you can convert it to a CEP 2.1.0 supported format other than JSON (such as Map, Tuple, XML) which you should be able to process without any issues.
Another approach might be to send JSON converted events via the REST API as in documentation sample provided in [1]. This API will convert the JSON events to Tuple Events by default.
Anyway, JSON Input mapping will be supported from the next CEP 3.0.0 release.
[1] http://docs.wso2.org/wiki/display/CEP210/Build+Analyzer
HTH,

Does Amazon provides customer phone through MWS

We have developed a simple application to retrieve orders for one of our customer. Our customer is a register sellers on amazon market place.
We are able to fetch the orders. Along with the orders info our client is asking for phone number of the customer. Amazon order do have a field called 'Phone' but we are always getting NULL value.
Actually does amazon expose customer phone number? If yes, how we can get that info?
Thanks.
There are multiple ways to retrieve order information through Amazon MWS. If you use the XML OrderReport format, you'll receive both buyer and delivery phone number as part of the XML data:
<Message>
<MessageID>1</MessageID>
<OrderReport>
<AmazonOrderID>...</AmazonOrderID>
...
<BillingData>
...
<BuyerPhoneNumber>123-456 7890</BuyerPhoneNumber>
</BillingData>
<FulfillmentData>
...
<Address>
...
<PhoneNumber>123-456 7890</PhoneNumber>
</Address>
</FulfillmentData>
</OrderReport>
</Message>
As of today the Phone number is given in ShippingAdress when retrieving orders.