reverse proxy and modify a soap request body

184 views
Skip to first unread message

neshant sharma

unread,
Mar 6, 2018, 1:48:35 AM3/6/18
to membrane-monitor
I intend to use SOA MEMBRANE as a reverse proxy for an important module. 
My Problem statement is fairly straightforward and half of it is accomplished using SOA Membrane ie forwarding of a request and getting a response.

I know I can modify request headers using this

<serviceProxy port="2000">
  	<javascript>
    	exc.getRequest().getHeader().add("X-Javascript", "Hello from JavaScript");
   		CONTINUE;
  	</javascript>
	<target host="localhost" port="8080" />
</serviceProxy>


What I am not able to figure out are two things. 

In a reverse proxy for SOAP service can I 

1) Can I modify SOAP request body based on some logic and forward it? I think I know I need to use an Interceptor.But I am not sure how would that look like ? Where do I write the code to do that? I want to be selective in modifying my request body and not modify every soap request. Only soap request for some methods need to be modified.
2) Can I modify a SOAP response to a SOAP request and return it to a client?

Is my requirement very complex?

I could not find any example in the documentation where a SOAP request body parameters are being modified for a method. It will be great to have an example for this use case if it is possible.

Thanks,
Neshant
Message has been deleted

neshant sharma

unread,
Mar 16, 2018, 2:03:33 AM3/16/18
to membrane-monitor
I have figured out most of the solution to my question and I will be posting a wiki on SOAP membrane github page. SOA Membrane is an excellent tool which gives you complete control on modifying SOAP request and and response.

Gunter Otté

unread,
Feb 2, 2021, 12:31:33 PM2/2/21
to membrane-monitor
Hello Neshant,

I can't find that Wiki on the Github page, and I have a similar use case like you had.
Can you share the details how you solved this? Thanks!

Regards,
Gunter

neshant sharma

unread,
Feb 2, 2021, 1:46:02 PM2/2/21
to membrane...@googlegroups.com
Hey Gunter ,

Unfortunately, I never posted the answer as it became a proprietary product for the company I was working for at the time.
I was able to achieve exactly what I wanted through interceptors and logics using Java.
The application ran flawlessly without any problems for the use case supporting millions of requests in a day.

If you share your use case a bit more detail maybe then I can guide you more.
Best,
Neshant



--
You received this message because you are subscribed to a topic in the Google Groups "membrane-monitor" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/membrane-monitor/CQ-apO7h7-k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to membrane-monit...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/membrane-monitor/18a9e039-0fbf-4ebb-a676-dea9b5d232c6n%40googlegroups.com.

Gunter Otté

unread,
Feb 2, 2021, 2:05:58 PM2/2/21
to membrane-monitor
Hello Neshant.

Thank  you for your quick reply!
What I want to do is fairly simple, I think :-)
We are hosting a translation software (XTM) which exposes a SOAP API. We don't give API credentials to anybody, it is for internal use only.
But now, a big client of us want to interface with it (via Drupal), and this requires a user&login of this API, which we don't want to give.
Now, I'm looking for a solution to set up a proxy, and alter the SOAP envelope for the credentials (and check on the requesters IP).
A basic SOAP envelope looks like this:

<soapenv:Header/>
<soapenv:Body>
<cus:findCustomer>
<loginAPI>
<userId>1234</userId>
<password>password0123456789</password>
<client>sample.com</client>
</loginAPI>
</cus:findCustomer>
</soapenv:Body>
</soapenv:Envelope> 

I want to replace those fake userid/password and client with the valid ones before it gets relayed to the actual host, and send the reply back to the client.
Is this possible through interceptors and java or Groove?

Thanks!


neshant sharma

unread,
Feb 2, 2021, 4:30:35 PM2/2/21
to membrane...@googlegroups.com
Hi Gunter,

Yeah this could totally be achieved and this is what I did.
The whole request and response can be modified and relayed and best part is no one would notice a difference that a proxy is sitting in between and doing these modifications! :D
Being a java developer , I feel more confident doing it in java and it gives more control to you.


So I provided a custom implementation of this method in my own class and This is how the function definition looks like for modifying/ playing with  the request

public
Outcome handleRequest(Exchange exchange) throws SOAPException, JAXBException, IOException {

         // exchange object has all the details about request and response. you could easily get the request body here from exchange like this
            exchange.getRequest().getBodyAsStreamDecoded()

         //  unmarshall it to a soap document and add your client and password and update the request in here

          // setting the request
            exchange.getRequest().setBodyContent(outputStream.toByteArray());
}

for sending the request, you will just need to configure the client address in the wsdl document or provide your own.

additional // If you want to modify the response you can do that

@Override
public Outcome handleResponse(Exchange exchange) throws IOException, SOAPException, JAXBException {

          exchange.getResponse().getBodyAsStreamDecoded()
          // basically do the same thing as you did in request modification
}


Hope this helps.

Best,
Neshant



--
You received this message because you are subscribed to a topic in the Google Groups "membrane-monitor" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/membrane-monitor/CQ-apO7h7-k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to membrane-monit...@googlegroups.com.

neshant sharma

unread,
Feb 2, 2021, 4:48:11 PM2/2/21
to membrane-monitor
Additionally ,  I used Springboot framework for all other sugarcoatings and configurations for the application.

Best,
Neshant

Gunter Otté

unread,
Feb 3, 2021, 3:01:21 AM2/3/21
to membrane-monitor
Hello  Neshant,

Thank you very much for your detailed answer, this will certainly help!

Best regards,
Gunter 

Gunter Otté

unread,
Feb 11, 2021, 10:50:17 AM2/11/21
to membrane-monitor
Hello  Neshant,

I got it working :-)
Thank you for pointing me in the right direction!

One more question. You suggested to use Springboot. I'm not familiar with it. Which advantages could it offer me for this use case?

Thanks!

Regards,
Gunter

neshant sharma

unread,
Feb 11, 2021, 11:35:07 AM2/11/21
to membrane...@googlegroups.com
Awesome! you don't need to use it, as I mentioned earlier it takes away the need of creating a lot of extra boiler plate code.
It makes configuration for the application easier. Also a lot of automatic stuff for a more manageable code.

From a philosophical point of view , if you are into building products for end customers and not necessarily developers then you are better off using
software tools which require you less effort/code as those tools are well tested and supported by the open source community.
For example the SOAP service that you are using is one such example :D

Best,
Neshant

Gunter Otté

unread,
Feb 11, 2021, 12:36:45 PM2/11/21
to membrane-monitor
Yes, you're right :-)
Thanks!

Reply all
Reply to author
Forward
0 new messages