简体   繁体   English

使用 Apache Camel 和 Z38008DD81C2F4D1185ACF6E0CE8 调用 SOAP web 服务

[英]Call SOAP web services by using Apache Camel and Spring Boot

I am new to Apache Camel.我是 Apache 骆驼的新手。 Currently I am trying to implement a use case where I need to consume a remote SOAP webservice using Spring Boot and Apache Camel.目前,我正在尝试实现一个用例,其中我需要使用 Spring Boot 和 Apache Camel 来使用远程 SOAP Web 服务。

Questions -问题 -

  1. Is it possible to make call from Spring Boot and Apache Camel integration?是否可以从 Spring Boot 和 Apache Camel 集成中拨打电话?
  2. What are the required dependencies should be used in this?应该使用哪些必需的依赖项?

Avinash阿维纳什

u can.你可以。 first u need get xsd of web services and create.xsd file in resources/ws folder首先,您需要获取 web 服务的 xsd 并在 resources/ws 文件夹中创建.xsd 文件

<xsd:schema targetNamespace="http://xx.com/xx" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://xx.com/xx">
<xsd:element name="MT_INPUT_REQUEST" type="DT_INPUT_REQUEST"/>
<xsd:complexType name="DT_INPUT_REQUEST">
    <xsd:annotation>
        <xsd:documentation xml:lang="EN">Key Account Order Header</xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
        <xsd:element name="x" type="xsd:string" minOccurs="0"/>
        <xsd:element name="y" type="xsd:string" minOccurs="0"/>
        <xsd:element name="ds" type="xsd:string" minOccurs="0"/>
        <xsd:element name="da" type="xsd:string" minOccurs="0"/>
        <xsd:element name="da" type="xsd:string" minOccurs="0"/>
        <xsd:element name="ddas" type="xsd:string" minOccurs="0"/>
        <xsd:element name="das" type="xsd:string" minOccurs="0"/>
        <xsd:element name="dsa" type="xsd:string" minOccurs="0"/>
        <xsd:element name="dasd" minOccurs="0" maxOccurs="unbounded">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element name="da" type="xsd:string" minOccurs="0"/>
                    <xsd:element name="dsa" type="xsd:string" minOccurs="0"/>
                    <xsd:element name="das" type="xsd:string" minOccurs="0"/>
                    <xsd:element name="da" type="xsd:string" minOccurs="0"/>
                    <xsd:element name="da" type="xsd:string" minOccurs="0"/>
                    <xsd:element name="das" type="xsd:string" minOccurs="0"/>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>
    </xsd:sequence>
</xsd:complexType></xsd:schema>

and after than u need create of this xsd 's class this plugin creates classs just run mvn clean install然后你需要创建这个 xsd 的 class 这个插件创建类只需运行 mvn clean install

<plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.14.0</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <encoding>iso8859-9</encoding>
                <schemaDirectory>${basedir}/src/main/resources/ws</schemaDirectory>
                <schemaIncludes>*.xsd</schemaIncludes>
            </configuration>
        </plugin>

u need one marshaller for java class to byte stream u can create this way你需要一个 java class 到字节 stream 的编组器你可以这样创建

public JaxbDataFormat marshaller() throws JAXBException {
    JaxbDataFormat jaxbDataFormat = new JaxbDataFormat(JAXBContext.newInstance("xx.com"));
    jaxbDataFormat.setEncoding("ISO-8859-9");
    jaxbDataFormat.setFilterNonXmlChars(true);
    return jaxbDataFormat;
}

after that u must create a class of xsds referanced and put body after thar unmarshall finally call之后,您必须创建一个引用的 xsds 的 class 并在 thar unmarshall 最终调用之后放置正文

.marshal(jaxbDataformat)
to("spring-ws:http://soapservice/bar")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM