-
1. Re: SOAP Web-Service
kcbabo May 12, 2014 11:00 PM (in response to steffi.s.)You can definitely invoke SOAP-based services through a reference and it's also possible to specify the operation within the service to invoke. If you are performing the invocation from a Camel route, then you can use the operationName parameter for switchyard:// endpoints, e.g.
-
2. Re: SOAP Web-Service
steffi.s. May 13, 2014 8:06 AM (in response to kcbabo)Hi Babo,
thank you for your answer. I tested it, but I got a NullPointerException:
------- Begin Message Trace -------
Consumer -> {urn:com.example.switchyard:HHESB:1.0}CamelServiceRoute/ExternalService
Provider -> {urn:com.example.switchyard:HHESB:1.0}ExternalService
Operation -> getPartDrawings
MEP -> IN_ONLY
Phase -> IN
State -> OK
Exchange Context ->
CamelAggregationStrategy .........................: {Splitter[on: XPath: getPartDrawings/partName/text() to: Channel[Channel[sendTo(Endpoint[switchyard://ExternalService?operationName=getPartDrawings])]] aggregate: null]=UseOriginalAggregationStrategy}
CamelCorrelationId ...............................: ID-strohmaierst-7-53581-1399979682957-0-4
CamelCreatedTimestamp ............................: Tue May 13 13:15:30 CEST 2014
CamelExceptionCaught .............................: org.switchyard.HandlerException: SWITCHYARD035429: Unexpected exception handling SOAP Message
CamelFailureEndpoint .............................: direct://%7Burn:com.example.switchyard:HHESB:1.0%7DCamelServiceRoute/ExternalService
CamelFilterMatched ...............................: false
CamelSplitComplete ...............................: true
CamelSplitIndex ..................................: 0
CamelSplitSize ...................................: 1
CamelToEndpoint ..................................: direct://%7Burn:com.example.switchyard:HHESB:1.0%7DCamelServiceRoute/ExternalService
org.switchyard.bus.camel.consumer ................: ServiceReference [name={urn:com.example.switchyard:HHESB:1.0}CamelServiceRoute/ExternalService, interface=SWITCHYARD010007: BaseServiceInterface [type=java, operations=[SWITCHYARD010008: NewOperation : IN_ONLY : [java:java.lang.String, null, null], SWITCHYARD010008: testoutput : IN_ONLY : [null, null, null], SWITCHYARD010008: getPartDrawings : IN_ONLY : [java:java.lang.String, null, null]]], domain=ServiceDomain [name=null]]
org.switchyard.bus.camel.contract ................: org.switchyard.metadata.BaseExchangeContract@4a7077b3
org.switchyard.bus.camel.dispatcher ..............: org.switchyard.bus.camel.ExchangeDispatcher@586be2c8
org.switchyard.bus.camel.labels ..................: {org.switchyard.exchangeGatewayName=[org.switchyard.label.behavior.transient], org.switchyard.exchangeInitiatedNS=[org.switchyard.label.behavior.transient], org.switchyard.exchange.transaction.beforeInvoked=[org.switchyard.label.behavior.transient], org.switchyard.security.context.SecurityContext=[org.switchyard.label.behavior.transient]}
org.switchyard.bus.camel.phase ...................: IN
org.switchyard.bus.camel.provider ................: Service [name={urn:com.example.switchyard:HHESB:1.0}ExternalService, interface=SWITCHYARD010007: BaseServiceInterface [type=java, operations=[SWITCHYARD010008: testoutput : IN_ONLY : [null, null, null], SWITCHYARD010008: getPartDrawings : IN_ONLY : [java:java.lang.String, null, null], SWITCHYARD010008: NewOperation : IN_ONLY : [java:java.lang.String, null, null]]], domain=ServiceDomain [name=null], metadata=org.switchyard.metadata.ServiceMetadataBuilder$ServiceMetadataImpl@430fc856]
org.switchyard.bus.camel.replyHandler ............: org.switchyard.component.camel.CamelResponseHandler@4dc347b7
org.switchyard.exchange.transaction.beforeInvoked : true
org.switchyard.exchangeGatewayName ...............: soap
org.switchyard.exchangeInitiatedNS ...............: 20348036462944
org.switchyard.operationName .....................: InputParameter
org.switchyard.security.context.SecurityContext ..: DefaultSecurityContext@1028246043[systemUUID=12a3fe76-ee8c-4ed0-a5dc-de2a19f044cd, expirationMillis=0, credentials=[], securityDomainsToSubjects={}]
org.switchyard.serviceName .......................: {urn:com.example.switchyard:HHESB:1.0}CamelService
Message Context ->
breadcrumbId ..............................: ID-strohmaierst-7-53581-1399979682957-0-1
org.switchyard.bus.camel.labels ...........: {org.switchyard.contentType=[org.switchyard.label.behavior.transient], org.switchyard.bus.camel.messageSent=[org.switchyard.label.behavior.transient], org.switchyard.transform.TransformSequence=[org.switchyard.label.behavior.transient]}
org.switchyard.bus.camel.messageSent ......: true
org.switchyard.contentType ................: java:java.lang.String
org.switchyard.messageId ..................: ID-strohmaierst-7-53581-1399979682957-0-5
org.switchyard.transform.TransformSequence : org.switchyard.transform.TransformSequence@604a8888
------ End Message Trace -------
Caught exception of type org.switchyard.HandlerException with message: SWITCHYARD035429: Unexpected exception handling SOAP Message
Caused by exception of type javax.xml.soap.SOAPException, message: java.lang.NullPointerException
Caused by exception of type java.lang.NullPointerException, message: null: org.switchyard.HandlerException: SWITCHYARD035429: Unexpected exception handling SOAP Message
at org.switchyard.component.soap.OutboundHandler.handleMessage(OutboundHandler.java:305) [switchyard-component-soap-1.1.0.Final.jar:1.1.0.Final]
at org.switchyard.bus.camel.processors.ProviderProcessor.process(ProviderProcessor.java:29) [switchyard-bus-camel-1.1.0.Final.jar:1.1.0.Final]
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]
at org.switchyard.bus.camel.audit.FaultProcessor.process(FaultProcessor.java:46) [switchyard-bus-camel-1.1.0.Final.jar:1.1.0.Final]
at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:117) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
at org.apache.camel.processor.TryProcessor.process(TryProcessor.java:104) [camel-core-2.10.0.jar:2.10.0]
My camel route is:
public class CamelServiceRoute extends RouteBuilder {
public void configure() {
from("switchyard://CamelService")
.log(
"Received message for 'CamelService' ")
.streamCaching()
.split()
.xpath("getPartDrawings/partName/text()").end()
.to("switchyard://ExternalService?operationName=getPartDrawings")
.end()
.end();In the interface I call the method of the Rest WebService
public interface CamelService
{
public void InputParameter (String partName);
}
The Rest Web-Service is create in the Interface WebServiceRessource_Camel
@Path("/")
public interface WebServiceResource_Camel {@POST()
@Path("/")
public void InputParameter (String partName);
}
In the interface of the reference I call the method of the SOAP WebService.interface ExternalService {
void getPartDrawings (String partName);
}
The input of the Post Web-Service is a XML Data.
<?xml version="1.0" encoding="UTF-8"?>
<getPartDrawings>
<partName>
1201.011.00
</partName>
</getPartDrawings>
The application starts by XML Data. Inside of Camel, I split the data depending on a certain parameter.
The result is a number. After this the number will be transported to a switchyard Reference. Inside the switchyard Service I call a SOAP Web-Service and invoke a special method.
I hope you can help me.
Best regards
-
3. Re: SOAP Web-Service
kcbabo May 13, 2014 8:24 AM (in response to steffi.s.)Can you attach your app? Are you using a Java or WSDL interface for the composite reference with the SOAP binding? Looking at your split logic, the reference is invoked with a string like "1201.011.00". The SOAP binding imports the message content into the SOAP Body as a child node, so if you pass along just the text value with no element definition that's going to cause problems. The easiest way to address this would be to have a component reference used by your Camel route with a Java interface as you defined above, then have a WSDL interface for the SOAP binding. This will require a transformer to map between the Java and XML types and in that transformer you can wrap the text value with the appropriate element definition defined in the message part of your WSDL.
-
4. Re: SOAP Web-Service
steffi.s. May 14, 2014 4:28 AM (in response to kcbabo)I`m not sure if I understand you correctly. At the moment I´m sending only the number (1201.011.00) as body to the Web Service.
In the picture you can see the SOAP Web-Service.
This means that I also have to send <partName> 1201.011.00 </partName> to the WebService.
I test it but I got a error message.
10:19:53,343 INFO [route3] (http-localhost/127.0.0.1:8080-1) Output : <SOAP-ENV:Fault xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><faultcode xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">S:Client</faultcode><faultstring>Cannot find dispatch method for {}getPartDrawings</faultstring></SOAP-ENV:Fault>
In the picture you can see the properties for the external service.
Sorry, that I ask again. But was is my mistake?