Best way to implement ebXml/ebMs with apache camel - apache-camel

First of all, I haven't found any generic open source implementation for ebxml/ebms, for me it's somehow strange or maybe I have looked up the wrong stuff, but I haven't found here something rly usefull.
When I was looking for ebxml/ebms I have also found JAXM/SAAJ(JSR 67). It looks like this implementations never got to an end, all links regarding this are refering to the sun homepage which doesn't exist anymore. From the sun homepage you get redirected to the oracle homepage, and there I can't find something about JAXM or JSR 67.
This leads me to my question, how to implement an ebxml service in apache camel?
Should I create the ebxml SOAP message "manually" or are there some libs I've missed that are generating such an ebxml message for me?`
How to send such an ebXml SOAP message via apache camel? Cxf needs an wsdl, for the service we want to call there exists no wsdl.
How to recieve such ebXml messages? Cxf see above, maybe with an http consumer like netty-http or jetty?

A few years too late, but maybe valuable for others :)
There is an open source implementation available which supports the ebMS 2.0 spec.
This ebMS adapter can be deployed as a Mule ESB plugin or as a regular WAR application.
https://sourceforge.net/projects/muleebmsadapter/
Despite being on sourceforge, it is still being actively developed.

You can use velocity template to create the ebxml SOAP message manually, for example.
Template example:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:ser="http://test/Service">
<soap:Header/>
<soap:Body>
<ser:insertRequest>
<ser:routingHeader>
<ser:operationType>${headers.OPERATION_TYPE}</ser:operationType>
<ser:messageId>${exchange.properties.messageId}</ser:messageId>
<ser:sourceId>${exchange.properties.sourceId}</ser:sourceId>
<ser:destinationId>${exchange.properties.destinationId}</ser:destinationId>
</ser:routingHeader>
<ser:datagram>
${body}
</ser:datagram>
</ser:insertRequest>
</soap:Body>
</soap:Envelope>
You can use http, http4 or jetty components to send such an ebXml SOAP message via apache camel.
to("jetty:http://{{server.host}}:{{server.http.port}}/service/").
log(LoggingLevel.INFO, "HTTP response code: ${in.header.CamelHttpResponseCode}")
After you only need to parse SOAP response manually (XPath, maybe), or you can transform response by XSLT.
Maybe you can use beanio, xstream or jaxb and so on to transform XML to POJO.
....
to("velocity:file:///{{karaf.home}}/etc/vm/ws-message-oc.vm?contentCache=true").
setProperty(Exchange.CONTENT_TYPE).constant("application/soap+xml").
setProperty(Exchange.CONTENT_ENCODING).constant("gzip").
setProperty(Exchange.CHARSET_NAME).constant("utf-8").
//log(LoggingLevel.INFO, "WS request: ${body}").
to("jetty:http://{{app-server.host}}:{{app-server.http.port}}/service/").
log(LoggingLevel.INFO, "HTTP response code: ${in.header.CamelHttpResponseCode}")
//log(LoggingLevel.INFO, "WS response: ${body}")
.setHeader("callRC").xpath("//ser:callRC/text()", String.class, XmlNamespaces.NAMESPACES.getNamespace())
....

Related

No endpoint could be found for - Camel Http Integration

I'm trying to run a simple test with Apache Camel:
from("http://localhost:61554/api/v1/MyController/my-endpoint")
.to("direct:a")
.log("$({body}");
I'm getting the following error: "No endpoint could be found for: http://localhost:61554/api/v1/MyController/my-endpoint, please check your classpath contains the needed Camel component jar"
I'm very new to Camel and Java. Can someone please tell me why this error is coming up? Should I be using from("direct:x")... ? If, so where do I map my "direct" endpoints to concrete ones?
Thanks
You cannot use the http component as consumer (eg in from) - its a http client for calling HTTP servers (so its a producer, eg to).
Instead to have HTTP as consumer you can use camel-servlet, camel-jetty, camel-undertow, etc.

Create proxy for Apache CXF Web services in wso2 ESB

I am a very beginner in ESB. So, kindly excuse me for this basic question.
Currently we have web services created with Apache CXF and Spring running. Now, we need to create proxy services for these in WSo2 ESB. Can someone please let us know how can we do this?
I created Pass Through proxy and use wsdl definition as from URL, but when i use try it option i get he endpoint reference (EPR) for the Operation not found is /services/ and the WSA Action = null.
If this EPR was previously reachable,please contact the server administrator.
Since ESB 4.6, pass-through transport is enabled by default : The message body is not build so, SOAP Body based dispatching is not supported => in this case, the error you're speaking about is thrown
One solution could be to add this parameter in your proxy conf : <parameter name="disableOperationValidation" locked="false">true</parameter>
Have a look there for other options : Using WSO2 ESB PassThrough Proxy on WebLogic (Spring) Web Service
How did you create the proxy service? If you have the wsdl of the Backend service you can use it to create the proxy service like follows.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="testProxy2" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<outSequence>
<send/>
</outSequence>
<endpoint>
<wsdl service="SimpleStockQuoteService"
port="SimpleStockQuoteServiceHttpSoap11Endpoint"
uri="http://localhost:9000/services/SimpleStockQuoteService?wsdl"/>
</endpoint>
</target>
<description/>
</proxy>
The ESB gets the endpoint url from the Service name and Port defined in the WSDL. For SOAP 1.1 the WSA action will be the SOAPAction header and for SOAP 1.2 the WSA action goes with the action element of Content-Type header. For example,
Content-Type: application/soap+xml;charset=UTF-8;action="TheSoapAction"
Try to use a SOAP client like SOAPUI to test your proxy service.

Caused by: javax.xml.ws.soap.SOAPFaultException: A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint

I don't know what I changed anymore :(... But I have ended up with this exception which I don't seem to solve:
Caused by: javax.xml.ws.soap.SOAPFaultException: A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint.
I am using CXF 2.7.4 and have the classes generated from the wsdl.
I am using the MTOM and WSS4JOutInterceptor for signing outgoing messages.
The wsdl contains things like:
<wsdl:definitions ... xmlns:soap11="http ... >
<soap11:binding
<soap11:operation
soap11:address
So that all sound like soap 1.1, but somehow soap 1.2 is being used in the client for the created message.
I have added this in my jaxws client config, but it had no effect.
<jaxws:binding>
<soap:soapBinding version="1.1"/>
</jaxws:binding>
Why does CXF try to use soap 1.2 at all?
Please some advice on how to solve this?
- Ed
I think it is because incoming message is in SOAP1.2 format.
See if it contains references to namespace http://www.w3.org/2003/05

Force.com callout: Is there a way to get the full response from the target server

When calling a web service from Force.com, I am getting:
System.CalloutException: Web service callout failed: Unexpected
element. Parser was expecting element
'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'
The network guys at the other end has asked to see the full response that Salesforce is getting from their server.
Is there a way to achieve that? I have tried running with debug level 'Finest' from execute anonymous, but that yields the same little message with no further detail.
The message you are getting is because an error is generated as Saleforce is trying to parse the response is and it isn't logged unfortunately.
The parsing error is happening because instead of a SOAP message response you are getting an HTML page. This usually happens when you are accessing a service that is protected behind a firewall. Which means you may be able to see the service when browsing on your computer but remember that Salesforce is outside of your firewall and thus any communication by Salesforce to your service will be blocked.
Couple of ways to address this but this wiki topic from Salesforce best covers the options:
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_om_outboundmessaging_security.htm
The above is specific to outbound messaging but essentially the technology issues are the same.
Don't forget that Apex includes an HttpRequest Class that works as a lower layer than the SOAP APIs. You should be able to write up a test method that sends a hard-coded XML request to the server and dumps the HttpResponse so you can see it.
Adding my own best answer, based on some internet research:
You can use an external tool like Runscope as a webservice proxy to automatically forward requests and pass through responses and view the XML SOAP messages. This is not a native solution on SFDC but it does do the job.
https://www.runscope.com/
The issue is that Force.com is trying to parse a SOAP response that's actually just HTML. This happens sometimes when an error occurred server-side and the response is meant for a browser to display, rather than sending back an exception report via a properly formatted SOAP response.
If they can't figure out why they are not sending back a consumable SOAP response, then you can try using other tools (outside of Force.com) to make the same webservice call from your browser and then see what the HTML actually says on return.

How to Send POST method with multipart request using CAMEL

How to Send POST method with multipart request using CAMEL
I have an application with camel setup and i need to attach documents and send and HTTP POST request.
How can i do this,
You can always write some java code with the apache httpcompenents library. see http://hc.apache.org/
It is not difficult to use

Resources