Générer une requête soap à l'aide de Chameau

Je veux l'appeler tiers webservice de chameau à l'aide de fichier wsdl sans génération de code client(parce que je pense que si je suis en fournissant fichier wsdl puis chameau en mesure de générer des clients que nous avons déjà générer et qui travaille dans notre vieux code)

Après avoir cherché longtemps, j'ai trouvé un code qui m'aide à atteindre mon objectif

code est

import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.dataformat.soap.Soap11DataFormatAdapter;
import org.apache.camel.dataformat.soap.Soap12DataFormatAdapter;
import org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.model.dataformat.SoapJaxbDataFormat;
import com.camel.model.Application;
public class TestMain {
static CamelContext context;
public static void main(String args[]) throws Exception {
CamelContext context = new DefaultCamelContext();
ProducerTemplate template = context.createProducerTemplate(0);
context.start();
String url="cxf://http://localhost:8081/buzzor-service/services/ApplicationService?" +
"wsdlURL=http://localhost:8081/buzzor-service/services/ApplicationService?wsdl&" +
"serviceName={http://service.application.buzzor.atpl.com}ApplicationService&" +
"portName={http://service.application.buzzor.atpl.com}ApplicationServiceHttpPort&" +
"dataFormat=MESSAGE";
Exchange reply = sendSimpleMessage(template, url);
org.apache.camel.Message out = reply.getOut();
String result = out.getBody(String.class);
System.out.println(result);
Thread.sleep(10000);
context.stop();
}
private static Exchange sendSimpleMessage(ProducerTemplate template,
String endpointUri) {
Exchange exchange = template.request(endpointUri, new Processor() {
public void process(final Exchange exchange) throws Exception {
exchange.getIn().setBody("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ "<soap:Body><ns1:getApplication xmlns:ns1=\"http://cxf.component.camel.apache.org/\">"
//                        + "<arg0 xmlns=\"http://cxf.component.camel.apache.org/\">hello world</arg0>"
+ "</ns1:getApplication></soap:Body></soap:Envelope>");
System.out.println(exchange.getIn().getBody());
}
});
return exchange;
}
}

cela fonctionne correctement, mais je suis ici générer manuellement Enveloppe soap

fichier wsdl est

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://service.application.buzzor.atpl.com" xmlns:ns1="urn:http://model.application.buzzor.atpl.com" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:tns="http://service.application.buzzor.atpl.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.application.buzzor.atpl.com">
<xsd:element name="getApplication">
<xsd:complexType/>
</xsd:element>
<xsd:element name="getApplicationResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="addApplication">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="ns1:Application"/>
<xsd:element maxOccurs="1" minOccurs="1" name="in1" nillable="true" type="ns1:User"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="addApplicationResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="ns1:ApplicationResult"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="urn:http://model.application.buzzor.atpl.com">
<xsd:complexType name="Application">
<xsd:sequence>
<xsd:element minOccurs="0" name="APP_ID" nillable="true" type="xsd:int"/>
<xsd:element minOccurs="0" name="APP_NAME" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="APP_PASSWORD" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="APP_TYPE" nillable="true" type="xsd:int"/>
<xsd:element minOccurs="0" name="APP_VERSION" nillable="true" type="xsd:int"/>
<xsd:element minOccurs="0" name="EXCEPTION_HANDLED" nillable="true" type="xsd:int"/>
<xsd:element minOccurs="0" name="IS_LOGIN_REQUIRED" nillable="true" type="xsd:int"/>
<xsd:element minOccurs="0" name="LONG_CODES" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="PREVIOUS_NODE_KEY" nillable="true" type="xsd:int"/>
<xsd:element minOccurs="0" name="REPLY_TEXT" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="WELCOME_NOTE" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="User">
<xsd:sequence>
<xsd:element minOccurs="0" name="ACTIVE_STATUS" type="xsd:int"/>
<xsd:element minOccurs="0" name="CUSTOMER_ID" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="FIRST_NAME" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="IS_ADMIN" type="xsd:int"/>
<xsd:element minOccurs="0" name="LAST_NAME" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="LOGIN_USER_ID" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="LOGIN_ALLSC" type="xsd:int"/>
<xsd:element minOccurs="0" name="USER_ACTION" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="USER_CONFIRM_PASSWORD" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="USER_ID" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="USER_PASSWORD" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="USER_PATH" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="USER_STATUS" type="xsd:int"/>
<xsd:element minOccurs="0" name="USER_TYPE" type="xsd:boolean"/>
<xsd:element minOccurs="0" name="VERSION_ID" type="xsd:double"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ApplicationResult">
<xsd:sequence>
<xsd:element minOccurs="0" name="APP_ID" nillable="true" type="xsd:int"/>
<xsd:element minOccurs="0" name="APP_NAME" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="ERROR_MESSAGE" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="ERROR_STATUS" nillable="true" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="addApplicationRequest">
<wsdl:part name="parameters" element="tns:addApplication">
</wsdl:part>
</wsdl:message>
<wsdl:message name="addApplicationResponse">
<wsdl:part name="parameters" element="tns:addApplicationResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getApplicationResponse">
<wsdl:part name="parameters" element="tns:getApplicationResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getApplicationRequest">
<wsdl:part name="parameters" element="tns:getApplication">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="ApplicationServicePortType">
<wsdl:operation name="getApplication">
<wsdl:input name="getApplicationRequest" message="tns:getApplicationRequest">
</wsdl:input>
<wsdl:output name="getApplicationResponse" message="tns:getApplicationResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="addApplication">
<wsdl:input name="addApplicationRequest" message="tns:addApplicationRequest">
</wsdl:input>
<wsdl:output name="addApplicationResponse" message="tns:addApplicationResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ApplicationServiceHttpBinding" type="tns:ApplicationServicePortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getApplication">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getApplicationRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getApplicationResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="addApplication">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="addApplicationRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="addApplicationResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ApplicationService">
<wsdl:port name="ApplicationServiceHttpPort" binding="tns:ApplicationServiceHttpBinding">
<wsdlsoap:address location="http://localhost:8081/buzzor-service/services/ApplicationService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

maintenant, je veux générer une requête soap plutôt que statique

s'il vous plaît aider moi

Merci d'avance

OriginalL'auteur Darshan Patel | 2014-01-02