WSO2 API Manager (WSO2-AM) and Web services addressing (WS-A ) - wso2

I've a SOAP web services hosted in a Weblogic Server that uses Web service addressing (WS-A). I'm trying to publish it using WSO2 API Manager.
The original request has a complete SOAP header including an Action and MessageID:
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Action>urn:es:cetelem:ws:venta:promociones:services:promocionesService:promocionesService_v03:PromocionesServicePortType:obtenerPromocionesOperacionVndRequest</wsa:Action>
<wsa:MessageID>uuid:969e636c-067f-4bed-a38a-65f0f81c295d</wsa:MessageID>
</soapenv:Header>
But the wso2-am removes the fields Action and MessageID from the SOAP Header before sending to the final endpoint in the Werblogic server. This is an example of the wrong hearder sent by wso2-am
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"/>
How can I configure wso2-am to keep the SOAP Header sent by the client.

I found a solution. I added a new sequence mediation extension in [CARBON-HOME]/repository/deployment/server/synapse-configs/default/sequences to preserve original WS-A headers. The new extension set to true the PRESERVE_WS_ADDRESSING property.
Visit https://docs.wso2.com/display/ESB460/Generic+Properties .
The code of the new mediator is:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="WSO2AM--Ext--In">
<property name="PRESERVE_WS_ADDRESSING" value="true" scope="default" type="STRING"/>
</sequence>

Related

WSO2 EI and WSO2 Developer - Setup an ESB Proxy with http basic authentication

I'm using WSO2 EI 6.3.0 and WSO2 Developer Studio 3.8.0.
I'm working with an ESB Project and a Proxy Service inside it.
The Proxy service is a simple pass through service;
it receives a request from a webapp and forward it to a
Soap Web Service, gets the response from the WS and gives
it back to the web app.
I realized this configuration following this tutorial:
https://youtu.be/3OsuGhEMQgc
The setup is very simple, everything worked fine until I found
a web service whose endpoint has http basic authentication.
I made it work thanks to this article:
https://medium.com/#Jenananthan/wso2-esb-how-to-invoke-basic-auth-protected-endpoint-service-5bcdd8290cb4
Here follows the xml that describes the proxy service:
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="ProxyWithBasicAuth" startOnLoad="true" trace="disable" transports="https" xmlns="http://ws.apache.org/ns/synapse">
<target>
<endpoint name="endpoint_urn_uuid_xxxxxxxx-yyyy-zzzz-1111-234567892345">
<address trace="disable" uri="https://here.goes.the.uri.of.the.ws.endpoint"/>
</endpoint>
<inSequence>
<property value="this_is_the_username" name="username" scope="default" type="STRING"/>
<property value="this_is_the_password" name="password" scope="default" type="STRING"/>
<property expression="fn:concat($ctx:username,':',$ctx:password)" name="credentials" scope="default" type="STRING"/>
<property expression="fn:concat('Basic ', base64Encode($ctx:credentials))" name="Authorization" scope="transport" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</target>
</proxy>
So, this configuration (xml file) is working, but I wrote all
the section that enables basic auth without using any visual or drag and drop element of the gui.
My questions are:
1) is this the right way to setup basic auth on a proxy service?
2) is there any gui (drag and drop) element that allows to do this setup visually?
Note: I do not need to struggle with basic authentication between
"clients" and the ESB Proxy Service; this question is about basic
authentication between ESB Proxy Service and an "external" web service.
What you have done is correct. To invoke a service secured with Basic Auth, we just have to set the Authorization header to the message. You could use Header Mediator[1] or the Property mediator (as you have already used) to do that. There is no special Mediator (or a GUI element in the Tool) specifically designed for setting the Authorization header.
Btw, you could consider storing passwords in the secure-vault[2] rather than having it in plain text in the Synapse configuration.
[1] https://docs.wso2.com/display/EI640/Header+Mediator
[2] https://docs.wso2.com/display/EI640/Working+with+Passwords+in+the+ESB+profile

Esb incorrectly adding its context to the endpoint URL

I'm currently developing a proxy service using ESB. The service first uses a callout mediator to call a service in DSS and after calls the final endpoint. The DSS endpoint is defined as a WSDL endpoint.
The proxy service URL is, e.g. <host>/esb/services/exampleService, and when I send a post to the service it tries to add this context to the URL of the DSS endpoint, giving out an exception in DSS, namely:
The service cannot be found for the endpoint reference (EPR) <host>/services/dssservice.SOAP11Endpoint/esb/services/exampleService
Is there a way to stop ESB from adding on to the URL?
Callout Configuration:
<callout action="urn:exampleservice" endpointKey="DSSEndpoint"initAxis2ClientOptions="false">
<source type="envelope"/>
<target
xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
</callout>
If you require more information, just ask.
Try to define this property before call mediator :
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>

WSO2 - cookie on second call in Service Proxy

I need to make proxy service in wso2 esb, that would be redirect requests to external wsdl service with pre send auth request to separate operation.
I make sequence like this:
clone
payloadFactory (auth xml request)
call (auth operation)
property (value=get-property('transport', 'Set-Cookie'), name=ExtCookie scope=operation)
property (value=get-property('operation', 'ExtCookie') name=Cookie)
Send (target operation)
When I make first call to this proxy service - It's work fine. But on second call I see in tcpdump that there is Cookie HTTP Header in the clone request.
I try add "property remove" with different scope(transport, operation, Synapse, default, axis2, axis2-client), but no one work. Cookie-Header wasn't removed. I need remove it for correct work with ext service.
Try with the following properties.
<property name="EXCESS_TRANSPORT_HEADERS" scope="axis2" action="remove"/>
<property name="Set-Cookie" scope="transport" action="remove"/>

WSO2 soap12 endpoint to soap11 external service

I create a simple WSDL proxy in WSO2 to allow Soap 1.2 enabled applications to work with Soap 1.1 only external web service. Everything is fine except WSO2 doesn't transform soap11 replies back to soap12 when I send request via Soap12 WSO endpoint.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="MySOAP" transports="http"
statistics="disable" trace="disable" startOnLoad="true">
<target>
<endpoint>
<wsdl service="ExtService" port="ExtPort" uri="https://my.local/wsdl/current
/ExtService.wsdl"/>
<property name="DISABLE_CHUNKING" value="true" scope="axis2"/>
</endpoint>
</target>
<publishWSDL uri="file:///home/sysadmin/MySOAP.wsdl"/>
<description></description>
</proxy>
Has anybody faced anything similar? WSO2 ESB version 4.6.0
You need to add the format as following.
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService" format="soap11" />
</endpoint>
Format - The message format for the endpoint. The available values are:
[format="soap11|soap12|pox|get"]
Leave As-Is - No transformation is done to the outgoing message.
SOAP 1.1 - Transforming message to SOAP 1.1.
SOAP 1.2 - Transforming message to SOAP 1.2.
Plain Old XML (POX) - Transforming to plain old XML format
Representational State Transfer (REST) - Transforming to HTTP Get
Request
GET
http://docs.wso2.org/wiki/display/ESB460/Default+Endpoint
This has been an issue for a while now. See jira https://wso2.org/jira/browse/ESBJAVA-1994.
If you don't want to manually transform your response from the backend, uncomment the relevant NHTTP transport entries in axis2.xml and comment out the HTTP PassThrough transport entries.

How to put SOAP request and SOAP response in Log file in #EndPoint annotated class file

I am using this bean code to log request and response to the log file
<bean
class="org.springframework.ws.soap.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor">
<property name="logRequest" value="true" />
<property name="logResponse" value="true" />
</bean>
This works fine in the TOMCAT Application Server for logging SOAP Request and SOAP Response as it enters and leaves the #EndPoint class but not in the case of WebSphere Application Server V8.0. Is there any other method to put SOAP Request and SOAP response to the log file in SPRING-WS.
There is other way. See the documentation.
Anyway, why SoapEnvelopeLoggingInterceptor is not working with WebSphere? I have not experience with WebSphere but it could happen that your log configuration is being overwritten by the server one. Take a look to the server log configuration.