Consume SOAP API from WSO2 ECLIPSE Developer Studio

181 Views Asked by At

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!

2

There are 2 best solutions below

0
Maninda On

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.

0
Thishani Lucas On

(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.