How to validate part of message in WSOESB and choose first? - wso2-esb

Here is how it works.
I do have dss service that returns message of format
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dss="https://rmis33.r-mis.ru/services/dss">
<soapenv:Header/>
<soapenv:Body>
<dss:Requests>
<dss:Request>...</dss:Request>
<dss:Request>...</dss:Request>
<dss:Request>...</dss:Request>
....
<dss:Request>...</dss:Request>
</dss:Requests>
</soapenv:Body>
</soapenv:Envelope>
I have to split message on Request element and validate it, then choose first that pass validation over XSD.
It is hard to do on database level because it has a lot of elements(sub-elements) and XSD was already provided.

You can use validate mediator to validate XML messages against XML schema.There is a complete sample which demonstrates validating messages.

Related

web service consumer soap fault extraction

I am using web service consumer and calling a soap service and it will return below soap fault incase of number of hits reaches more than the limit. When the soap fault is caught in the error handler under the type WSC:SOAP_FUALT, I want to read the faultstring and if it is "Maximum request limit reached, please try again later.", I dont want to consider it as failure and point the payload for retry.
So please let me know how to extract the fault string inorder to put a check on it.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>Internal Server Error</faultcode>
<faultstring>Maximum request limit reached, please try again later.</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
The soap fault message returned by Web Service Consumer is stored within the errorMessage field in the error of the flow.
So you can use error.errorMessage.payload.Envelope.Body.Fault.faultstring to access that string in your error handler block, and use it in the when condition of the error handler itself to execute that handler when this message matches the required criteria. For example:
XML Code:
<on-error-continue enableNotifications="true"
logException="true" doc:name="On Error Continue"
doc:id="38283c80-4c20-46da-85e3-f47d5d5755b7" type="WSC:SOAP_FUALT"
when="#[(error.errorMessage.payload.Envelope.Body.Fault.faultstring default '') startsWith ('Maximum request limit reached')]">
<logger message="Error message caught by the error handler: #[error.errorMessage.payload.Envelope.Body.Fault.faultstring]" level="INFO" doc:name="Logger" doc:id="1f329e43-d401-412f-9479-f58bef4089c4" />
</on-error-continue>
You can use a simple DataWeave expression to extract the string:
%dw 2.0
output application/java
---
payload.Envelope.Body.Fault.faultstring
Output:
Maximum request limit reached, please try again later.

How to get URL pointing to specific candidate in Workday from WID

I've been try to figure out a way to get a URL pointing to a candidate's profile in Workday given a candidate's WID. My scenario is that I use the Put_Candidate operation (Workday Web Services SOAP API) to create a candidate which lets me know the WID and the Candidate_ID of the created candidate. From this returned information, I was hoping to construct the URL to the created candidate's profile in Workday. Is this possible? I'd appreciate any help/guidance that anyone can provide regarding this sort of scenario. Thank you.
I know its a little late, but if you are still looking for an answer then you can use
Get_workers api in Humar Resource Module and frame a request as below:-
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bsvc="urn:com.workday/bsvc">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>your username</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">your password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<wd:Get_Workers_Request xmlns:wd="urn:com.workday/bsvc" version="set appropriate version here">
<wd:Request_References bsvc:Skip_Non_Existing_Instances="false">
<wd:Worker_Reference >
<wd:ID wd:type="WID">Populate WID here</wd:ID>
</wd:Worker_Reference>
</wd:Request_References>
</wd:Get_Workers_Request>
</soapenv:Body>
</soapenv:Envelope>

SQL Query pulling extra data

I am using this query in SOAPUI against our SOAP API.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:del="http://tempuri.org/Deltek.Vision.WebServiceAPI.Server/DeltekVisionOpenAPIWebService">
<soapenv:Header/>
<soapenv:Body>
<del:GetProjectsByQuery>
<!--Optional:-->
<del:ConnInfoXML><![CDATA[<VisionConnInfo>
<databaseDescription>Description</databaseDescription>
<userName>USERNAME</userName>
<userPassword>PASSWORD</userPassword>
<integratedSecurity>Y</integratedSecurity>
</VisionConnInfo>]]></del:ConnInfoXML>
<!--Optional:-->
<del:Query>SELECT WBS1,Name,Principal FROM PR WHERE PR.WBS1='H15032.00'</del:Query>
<!--Optional:-->
<del:RecordDetail>'Project'</del:RecordDetail>
</del:GetProjectsByQuery>
</soapenv:Body>
</soapenv:Envelope>
The request goes through and gives me a response, however it gives me additional fields also. I just want to pull the column specified in query itself like WBS1, Name, and Principal fields only.
<WBS1>H15032.00</WBS1>
<Name>Name</Name>
<Principal>Principal Name</Principal>
<custLetterofIntent>Y</custLetterofIntent>
<custIssued>2015-06-03T00:00:00.000</c‌​ustIssued>
<CreateUser>KGOODENOW</CreateUser>
<CreateDate>2015-06-03T15:51:20.913</‌​CreateDate>
<ModUser>KGOODENOW</ModUser>
<ModDate>2015-06-03T15:52:29.227</ModDate>‌​
<CustContractStatus>LOI</CustContractStatus>
</ROW>
</Projects_ConsultantAgreements‌​>
</REC>
</RECS>]]>
</GetProjectsByQueryResult>
Am I missing something?

WCF Contract from XML Soap file

I have an inverse task about of WCF service construction.
Have a SOAP Request description XML file:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<nsp:run xmlns:nsp="http://someurl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://someurl/NewXMLSchema.xsd ">
<nsp:routes>
<nsp:process>number</nsp:process>
</nsp:routes>
<nsp:params>
<nsp:param name="name_1">?</nsp:param>
<nsp:param name="nam2_2">?</nsp:param>
</nsp:params>
<nsp:files>
<nsp:file name="file_1">b64Binary</nsp:file>
<nsp:file name="file_2">b64Binary</nsp:file>
</nsp:files>
</nsp:run>
</soapenv:Body>
</soapenv:Envelope>
need to design WCF contract which request has a similar description.
How can i do this?
You can't, really.
The SOAP XML file is just the data being sent to the service as a request or from the service as a response.
But that doesn't tell you how your service methods (your contract) should look like.....
The SOAP messages alone are not enough to define the service. You might be able to define the data structures (the data contract) for your WCF service, but not your service contract.
And you won't be able to even define your data contract with this SOAP XML file - since the relevant description of the data types and their structures appears to be hiding in the http://someurl/NewXMLSchema.xsd XML schema file .... unless you have that at hand, you're left with the names of the parameters, at best....

Web Service returning definition of response with initial value set

So I have a simple webservice that has an input of a userid and gets a flag from a sql database (initially set to '1').
However, when I query a user with the default value of the flag (which I set to 1 in SQL Server), I get the following response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<result xsi:type="ns1:getPWFlagResponse" xsi:nil="1" xmlns:ns1="<NamespaceURL>"/>
</soapenv:Body>
</soapenv:Envelope>
However, if I change the value of the flag, I Get the correct response for all other requests:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<result>
<result>1</result>
</result>
</soapenv:Body>
</soapenv:Envelope>
(Same for result of 0 ).
I thought that it could be that I didn't initialize something at first, however if I don't set an initial value on the PWResetFlag column in the table the webService comes back with the correct response.
Is this something with SQL server and setting default values or something on my end?
Thanks
Just wanted to update the question in case anyone else has had similar problems, but I have found the root source of my problem. I was using TOAD for sql server to do my table alterations, but when I went on to the actual server and into the database, the flag was set to NULL as a default value despite me altering it to not accept nulls and applying a default value of 1.
I did the alterations directly in SQL Server on the machine which correctly applied the default value and now my webservice is working perfectly!
Thanks