I need solution to consume two SOAP APIs .
First i have a wsdl url which will work once certificate installed on machine i just want to ask that is there any type of configuration need to be done on developer studio while creating the flow.
Second i need to make a flow in wso2 developer studio which will call a SOAP WSDL URL and gives response but the problem is that the wsdl contains security policy username-token ws-security configuration any expert tell me the flow for that.
Both scenarios work in SOAP UI tool. I am new to wso2 anyone can help me in this??
Thanks in advance!
For the first question the answer is no. Certificate of the server should only be stored in the client side. When a TLS/SSL enabled URL is called, the server's certificate should be stored in the client's trust store. If your client is a WSO2 server, then that certificate should be imported to the client-truststore.jks of the WSO2 server. That is deployment specific. Nothing has to be done during the artifacts are developed in the Developer Studio.
(1) There isn't anything to be done with dev studio. You need to import the backend's certificate to the trust store of the WSO2 server.
(2) You can create a proxy service and call the secured backend. Since your backend is secured by UT policy, you have to construct a username token when calling it. We can use a class mediator to construct and set a username token.
More details can be found at : http://xacmlinfo.org/2014/03/25/how-to-esb-invoking-username-token-secured-backend-service/
Following is the simplified version of the class mediator.
public class UTTokenBuilder extends AbstractMediator{
#Override
public boolean mediate(MessageContext messageContext) {
try {
org.apache.axis2.context.MessageContext context = ((Axis2MessageContext) messageContext)
.getAxis2MessageContext();
context.getOptions().setUserName("admin");
context.getOptions().setPassword("admin");
return true;
} catch (SynapseException e) {
throw e;
} catch (Exception e) {
throw new SynapseException("Error while building UT Token");
}
}
}
And following is the sample proxy to call the secured backend.
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="sec2"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<inSequence>
<class name="org.soasecurity.wssecurity.ut.mediator.UTTokenBuilder"/>
<call>
<endpoint>
<address uri="https://localhost:8243/services/secTestProxy">
<enableSec policy="conf:/UTPolicy.xml"/>
</address>
</endpoint>
</call>
<respond/>
</inSequence>
</target>
<description/>
</proxy>
Please note I've used an address endpoint for simplicity.
Related
I am very new in WSO2 and I have the following doubt related to an ESB project on which I am working.
In this ESB application I am sending a message to a named endopoint mediator, something like this:
<send>
<endpoint key="echoEndpoint"/>
</send>
This is the contend of the related echoEndpoint.xml file in my project:
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="echoEndpoint" xmlns="http://ws.apache.org/ns/synapse">
<address format="soap11" statistics="enable" trace="enable" uri="http://localhost:8280/services/echo"/>
</endpoint>
So what exactly does this endpoint? The http://localhost:8280/services/echo is something like a predefined endopoined provided natively by WSO2? or what?
echo service included into esb/ei by default. You can see it in Carbon Panel -> Main -> Manage -> Services. There you can test it via "Try It" feature. It has few methods:
echoInt extected to get integer as argument and returned same integer value
echoString - expected to get string value as argument and returned same value
echoOMElement - received XML as argument and returned same XML
and some other methods. General idea - this service returned same value as it is received.
This service is helpful for testing purposes.
This is a service that by default is already displayed when you run the ESB. Echo.aar is located in the path repository\deployment\server\axis2services . And wsdl you can see https://localhost:your_Port/services/echo?wsdl
How to develope a web service in WSO2 using proxy services ?
Applying my Oracle Service Bus knowledge here to create a proxy service which would take a string as an Input and return the same as response, I find it difficult in WSO2 to create a proxy service using my XML Schema.
I found that we can do the same in WSO2 using Custom proxy template.
But I am not sure of defining an Input and output in proxy service ;
In a traditional Oracle Service Bus we can do it by defining our XMl Schemas.
Seems like you need some echo kind of a service. This kind of behavior can be achieved by configuring the wso2 esb as in following manner. However this is not really a web service. I hope you are aware of what is web service and what does a proxy service does. But for your requirement you can try something like follows.
<proxy name="loopBackProxy" startonload="true" statistics="disable" trace="disable" transports="https,http" xmlns="http://ws.apache.org/ns/synapse">
<target>
<insequence>
<log level="full"></log>
<header action="remove" name="To"></header>
<property name="RESPONSE" value="true"></property>
<!-- your esb modifications here -->
<send></send>
</insequence>
</target>
<description></description>
</proxy>
This doesnot contains a outsequence, what this does is redirects the input to the client.
i need to extend the LoadBalance Endpoint developing my custom endpoint.
I tried:
1)
public class CustomLoadBalanceEndpoint extends LoadbalanceEndpoint
2) i exported it using wso2 studio in the /repository/components/dropins folder
3) i cannot find the way to use it inside ESB... I tried with this code
<endpoint class="it.innovapuglia.sistemapuglia.wso2.enpoint.CustomLoadBalanceEndpoint"
algorithm="org.apache.synapse.endpoints.algorithms.RoundRobin">
<endpoint name="tomcat1">
<address uri="http://localhost:8080/RestService/rest/servizio"/>
</endpoint>
</endpoint>
but ESB doesn't accept it saying me "Proxy service requires a valid in sequence or a valid endpoint."
You can not use your endpoint like that.
After developing your custom endpoint keep that in the repository/components/lib folder.You have to call your endpoint like this;
<endpoint name="CustomEndpoint">
<class name="org.wso2.carbon.endpoint.CustomLoadBalanceEndpoint">
</class>
</endpoint>
Check the following posts on how to add your custom endpoint concepts.
[1]http://vvratha.blogspot.com/2012/07/class-endpoints-in-synapse.html
[2]http://vvratha.blogspot.com/2013/06/class-endpointssample.html
I want to cache the response in my proxy and when i hit my proxy again then it should get me the cached data. I have tried using Cache mediator but am unable to find if my data is really getting cached or not.So basically what i am trying to achieve is if i have data in cache then it shouldn't hit the endpoint.It should send the response from cache. Looking forward to your answer. Thanks in advance
I have my service code as:
public class GetMirrorValue {
public String getValue(String data) throws Exception {
System.out.println("Inside Service code");
return data;
}
}
my inSequence is:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="CheckCacheSeq">
<cache scope="per-host" collector="false" hashGenerator="org.wso2.caching.digest.DOMHASHGenerator" timeout="20">
<implementation type="memory" maxSize="100"/>
</cache>
<send>
<endpoint key="DummyEP"/>
</send>
</sequence>
and my out sequence is:
<outSequence xmlns="http://ws.apache.org/ns/synapse">
<cache scope="per-host" collector="true"/>
<send/>
</outSequence>
but whenever i hit my proxy service consecutively through try-it tool, i get data from service but not from cache coz every time in my server System.out.println("Inside Service code"); gets printed?
You can modify your backend service (The endpoint invoked by proxy service), to print something in the server log, once a request got hit. First request should hit the backend. Then within the cached period, requests won't go to the backend service. It will go to backend service only after cache is expired. So looking at the print on the backend server log, you can observe the caching behavior.
http://docs.wso2.org/wiki/display/ESB460/Sample+420%3A+Simple+Cache+Implemented+on+ESB+for+the+Actual+Service
You can enable wirelogs in ESB to see the requests/responses going through ESB.
How do I configure WSO2ESB such that I can proxy a service that I currently have hosted on Windows Azure?
On my local development machine I have an instance of WSO2ESB, I can use this to proxy WCF services also on my local development machine, but now I need to take this proof of concept work further and show how WSO2ESB could be used to proxy for WCF services hosted externally, in this instance on Windows Azure.
I have tried to add a new Proxy Service for my Azure service selecting Specify source URL for the Publishing WSDL and then entering the .svc address for my Azure service, but when I Test URI (which takes about a minute) it returns
Invalid WSDL URI (Unable to establish a connection)
I believe this to be caused by our corporate proxy and my machine needing to supply basic information in order to punch a hole out but I cannot see how / where to do this.
I am using WSO2ESB 4.5.1 and my Proxy Service source is:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Azure"
transports="https,http"
statistics="disable" trace="disable" startOnLoad="true">
<target>
<outSequence>
<send/>
</outSequence>
<endpoint>
<address uri="http://myazureservice.cloudapp.net/Service.svc"/>
</endpoint>
</target>
<description></description>
</proxy>
Update
I have also tried importing the WSDL the service generates by copying it to the clipboard and pasting it into WSO2 but this is rejected.
You can download the wsdl to your local filesystem with the extension of *.wsdl, and provide its link to the "publishWSDL" option