2016-07-31 31 views
1

Gemäß den Anweisungen in here und mit Hilfe von anderen Quellen, habe ich einen SoapClient erstellt, um eine SOAP-Anfrage zu senden und eine Antwort mit Apache Kamel zu erhalten.Senden Sie mehrere Parameter als requestBody mit Apache Camel ProdcerTemplate mit CxfComponent

Code:

CamelContext context = new DefaultCamelContext(); 

CxfComponent cxfComponent = new CxfComponent(context); 
CxfEndpoint serviceEndpoint = 
    new CxfEndpoint("http://www.webservicex.net/stockquote.asmx", cxfComponent); 

serviceEndpoint.setServiceClass(StockQuoteSoap.class); 

ProducerTemplate template = context.createProducerTemplate(); 

String getQuoteResponse = template.requestBody(serviceEndpoint, "test123", String.class); 

System.out.println(getQuoteResponse); 

Adjuscent JAX-WS-Aufruf:

String response = stockQuoteSoap.getQuote("test123") // stockQuoteSoap is created with JaxWsProxyFactoryBean using the ServiceClass StockQuoteSoap 

Dies funktioniert für die Web-Services-Fein nur einen Parameter als Anforderungs Körper zu erwarten. Ich möchte wissen, wie ich mehrere Parameter als Anfrage senden kann. (Ich müde RequestBodyAndHeader, assyncRequestBodyAndHeader usw.).

Adjuscent JAX-WS-Aufruf: mit Producertemplate mit CXFContext

SessionCreateRS sessionCreateRS = sessionCreatePortType.sessionCreateRQ(messageHeader, securityHeader, sessionCreateRQ); // sessionCreatePortType is created with JaxWsProxyFactoryBean using the ServiceClass SessionCreatePortType. messageHeader, securityHeader, sessionCreateRQ are in the type of WS generated with cxf-codegen-plugging. 

In diesem Fall sieht es immer für die Message als Anforderungs Körper Ich weiß nicht, wie die anderen Parameter zu senden. In JAX-WS funktioniert es perfekt, wenn alle Parameter in der oben beschriebenen Weise gesendet werden.

Antwort

1

Oh ich hatte eine dumme Antwort .. Ich habe sie einfach zu einer Liste hinzugefügt und gesendet. Es funktionierte!

ArrayList requestBody = new ArrayList(); 
requestBody.add(messageHeader); 
requestBody.add(security); 
requestBody.add(sessionCreateRQ); 

SessionCreateRS sessionCreateRS = template.requestBody(serviceEndpoint, requestBody, SessionCreateRS.class); 

Bitte teilen Sie eine bessere Antwort.