How to use REST API with SSRS 2012? - reporting-services

How to use REST API with SSRS 2012 ?
Is it even possible ? I had dataset where I called a webservice with SOAP but I don't know how I could modify this for a new REST api.
With SOAP I had this:
<Query>
<Method Namespace="http://foo.fr/webservices/" Name= "getContractXml">
<Parameters>
<Parameter Name="codeContract">
<DefaultValue>752125</DefaultValue>
</Parameter>
</Parameters>
</Method>
<SoapAction>http://foo.fr/webservices/getContractXml</SoapAction></Query>
How to change this to call a REST webservice, in https, with the same name and parameters?

Related

ESB WSO2 How to send an email from esb

I want to make an api for sending some emails from a SMTP server but I don't a user and a password to put in axis2.xml file.
So my axis2.xml file looks like this:
<transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
<parameter name="mail.smtp.host">email.example.ro</parameter>
<parameter name="mail.smtp.port">25</parameter>
<parameter name="mail.smtp.starttls.enable">true</parameter>
<parameter name="mail.smtp.auth">true</parameter>
<parameter name="mail.smtp.user"></parameter>
<parameter name="mail.smtp.password"></parameter>
<parameter name="mail.smtp.from">email#example.com</parameter>
</transportSender>
I searched on wso2 docs and I found that I have to do a proxy service for sending emails. Is it possible to do it with just an api?
I'm a real newbie with wso2 and my question is what should my proxy service look like and how can I call this service? (should I call it from an api, or what? because I want to send emails based on a value from a database).
#jakub.voves answer is correct. Let me add more details.
Proxy, APIs, Inbound Endpoints etc are a way to bring external messages into the system.(APIs help you to accept Restful invocation, Proxies allow you to consume SOAP messages, JMS Inbound Endpoints allow you to consume JMS messages from queues/topics) Once you receive the message you can use a combination of mediators to mediate the message.(Message transformations, calling different services etc.) So the mediators within a WSO2 environment are common to all types of services. Hence whatever mediators you use in proxy service can be used in APIs, or in Inbound Endpoints. Other than the mediators WSO2 also provides connectors to extend the functionality of the Server. So in conjunction with Mediators, you can use connectors as well. So in your case either you can use the mailto transport or you can consider using the Email connector. Email sending will look like something below with the connector.
<email.send configKey="smtpsconnection">
<from>{json-eval($.from)}</from>
<to>{json-eval($.to)}</to>
<subject>{json-eval($.subject)}</subject>
<content>{json-eval($.content)}</content>
</email.send>
One additional thing, If your SMTP server doesn't need authentication set the following property to false in axis2.xml.
<parameter name="mail.smtp.auth">false</parameter>
You can create api and try something like this
<property name="messageType" value="text/html" scope="axis2" type="STRING"/>
<property name="ContentType" value="text/html" scope="axis2" type="STRING"/>
<property name="Subject" value="Test Message" scope="transport" type="STRING"/>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<test xmlns="">This is a test email.</test>
</soapenv:Body>
</soapenv:Envelope>
</format>
</payloadFactory>
<send>
<endpoint>
<address uri="mailto:another.user#example.com"/>
</endpoint>
</send>
http://wso2experts.com/ei/send-email-from-wso2-ei-mailto-transport/

filtering json fileds without conditions using wso2 esb

In WSO2 ESB,how to pass certain json fields as request?
And adding the remaining json fields with the response?
You need to use API's if you want to pass json as the request, you can frame json request and test via SOAP UI by selecting the media type as application/json.
ESB will accept this request and then by default converts it into an XML format, you can use xpath to perform different instructions and then if you want json as the output of your API you need to use the below syntax before exiting your API.<property name="messageType" scope="axis2" type="STRING" value="application/json; charset=utf-8"/>
<property name="ContentType" scope="axis2" type="STRING" value="application/json; charset=utf-8"/>

How to host and transform SOAP message in WSO2

I am relative new in WSO2 to create services, and i have to do a project in the enterprise where i work. First i had to take a message in, for example, json and send xml. I was able to do so, with this code:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/Test" name="JsonToXmlApi" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST" uri-template="/xml/">
<inSequence>
<property name="messageType" scope="axis2" type="STRING" value="text/xml"/>
<header action="remove" name="To" scope="default"/>
<property name="RESPONSE" scope="default" type="STRING" value="true"/>
<send/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
Now i need to do the following, i have to send a message in SOAP, XML format, consume it in SOAP and receive back with JSON or XML format.
Someone could help me? I am asking because i am searching for tutorials, for beginners, about it for more than a week, and wasn't able to solve my problem.
Another question, would be possible to do this in REST API project?
If someone could help me, with a detailed tutorial or good video teaching that, i would be grateful.
Thank you.
Your post is a bit unclear but I will try to summarise the typical common combinations of input interface, wso2 component and backend services when you are developing web services.
Web services are services you can invoke over http or https - you might have three types of interfaces for these and you might use two types of WSO2 ESB components - proxy and API - to develop these.
1) Input/Output: JSON
WSO2 component: API
Backend: Any (JSon/XML/SOAP)
2) Input/Output: Plain XML
WSO2 component: API
Backend: Any (JSon/XML/SOAP)
3) Input/Output: SOAP
WSO2 component: Proxy
Backend: Any (JSon/XML/SOAP)
One of the key components of any SOAP service is the WSDL - the WSO2 proxy allows you to publish a WSDL so that your caller knows what sort of data and operations your service provides.
See more here: https://docs.wso2.com/display/EI611/Working+with+Proxy+Services
Adding this note only because you asked:
Technically, you might be able to receive a SOAP message in an API component because SOAP is just an XML document - but it would be really pointless. The purpose of the API component is to expose resources and allow you to perform HTTP operations (GET, POST etc) on those resources (this model can be called REST).
The purpose of a SOAP based web service is to expose data and operations as defined in a WSDL and the WSO2 proxy component is what allows you to do that.

411 Response on Post from WSO2 API Manager to REST endpoint

I have setup a REST endpoint in WSO2 AM that calls out to another REST endpoint. When the call is made I am receiving a 411 response code. The request contains a JSON body, the content type and accepts header are set to application/json. I can curl the backing service that WSO2 is accessing directly with the same params and it works correctly. It seems that WSO2 AM is stripping or not sending the content-length.
Why is the content length not being sent to the REST endpoint that is being accessed?
Sending content-length is disabled by default because it can cause performance degradation. But you can enable it by adding following to the api's insequence. (see https://docs.wso2.com/display/AM1100/Adding+Mediation+Extensions on adding custom sequence to an api)
<property name="COPY_CONTENT_LENGTH_FROM_INCOMING" value="true" scope="axis2"/>
<property name="FORCE_HTTP_CONTENT_LENGTH" scope="axis2" value="true"></property>
following is a sample sequnce
<sequence xmlns="http://ws.apache.org/ns/synapse" name="contentLengthadd">
<property name="COPY_CONTENT_LENGTH_FROM_INCOMING" value="true" scope="axis2"/>
<property name="FORCE_HTTP_CONTENT_LENGTH" scope="axis2" value="true"></property>
</sequence>
This sequence will get the content length from incoming request request and pass it the request header to the backend.
you can read more about these two properties in https://docs.wso2.com/display/ESB481/HTTP+Transport+Properties#HTTPTransportProperties-FORCE_HTTP_CONTENT_LENGTH

Terminating send mediator with mailto transport wso2 esb

There are numerous examples of using the mailto transport in WSO2 ESB to send emails (based on filter mediator, fault sequence etc.). However, I have attempted this a number of ways all with the same result i.e. that the proxy service never terminates. I am testing this using SOAPUi.
This is my proxy service
<proxy xmlns="http://ws.apache.org/ns/synapse" name="TMCService" transports="https,http" statistics="enable" trace="enable" startOnLoad="true">
<target inSequence="gov:/trunk/sequences/seqGetTMCData">
<outSequence>
<filter xmlns:trac="http://mynamespaceuri" xpath="//trac:SaveIncidentsResponse">
<then>
<log level="full"/>
<property name="Subject" value="CEP Event" scope="transport"/>
<property name="OUT_ONLY" value="true"/>
<send>
<endpoint>
<address uri="mailto:conrad.crampton#gmail.com"/>
</endpoint>
</send>
</then>
<else>
<send/>
</else>
</filter>
</outSequence>
</target>
<description></description>
</proxy>
the email sends no problem with the response from the inSequence - no problem, it just never terminates. I have to manually stop it in SOAPUi to stop.
I've tried putting drop after the send in the then element, that doesn't work either.
I guess I am missing something fundamental in how I am understanding the out sequence to work, but this is pretty much lifted from the many examples out there and no one else appears to be having the same issue as me.
Any suggestions/ pointers??
WSO2 ESB v4.5.1
I have resolved this by cloning the response message, sending one to the mailto transport and sending the other one as a default send (no endpoint) which returns back to the client.
Kind of makes sense as the OUT_ONLY property is explicitly saying there will be no response, so have ensure that the client receives one by cloning the message.
Still welcome any other comments if there is another way of doing this without clone mediator.
So why doesn't the examples show this!