2017-12-11 22 views
0

こんにちは私はCamel-SOAPコンポーネントを使用して、MQを使用して送信されたSOAPメッセージを非整列化しようとしています。 しかし、私は、XSD年代をprovieded WSDLを使用して、生成された私のJAXB Beanに達人-JAXB2-プラグインを使用していることにより、必要なServiceInterfaceStrategyとSoapJaxbDataFormatCamel-SOAP unmarshalの使い方

を使用する方法を見つけ出すことはできません。

どのクラスを使用しますか?
そして、どうすればmaven-jaxb2-pluginで生成できますか?

SoapJaxbDataFormat soap = new 
SoapJaxbDataFormat("xx.xxx.service._201x._01._01.notification", new 
ServiceInterfaceStrategy(WHAT_CLASS_TO_USE.class, false)); 

答えて

1

そして、どのように私はのmaven-JAXB2 - プラグインとそれを生成するのですか?

<plugin> 
    <groupId>org.jvnet.jaxb2.maven2</groupId> 
    <artifactId>maven-jaxb2-plugin</artifactId> 
    <version>0.13.1</version> 
    <executions> 
     <execution> 
      <id>generate</id> 
      <goals> 
       <goal>generate</goal> 
      </goals> 
      <configuration> 
       <schemaDirectory>src/test/resources/wsdl</schemaDirectory> 
       <generatePackage>org.tempuri.calculator.jaxb2</generatePackage> 
       <generateDirectory>src/test/java</generateDirectory> 
       <clearOutputDir>false</clearOutputDir> 
       <episode>false</episode> 
       <strict>true</strict> 
       <schemaIncludes> 
        <schemaInclude>*.wsdl</schemaInclude> 
        <schemaInclude>*.xsd</schemaInclude> 
       </schemaIncludes> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

ソースを生成するためのMavenコマンドは次のとおりです:mvn generate-sourcesプラグインを使用して、クラスファイルを生成するに

は、次のような構成を試してみてください。

どのクラスを使用しますか?

protected SoapJaxbDataFormat createDataFormat() { 
    String jaxbPackage = Add.class.getPackage().getName(); 
    ElementNameStrategy elStrat = new TypeNameStrategy(); 
    SoapJaxbDataFormat answer = new SoapJaxbDataFormat(jaxbPackage, elStrat); 
    answer.setVersion("1.2"); 
    return answer; 
} 

@Override 
protected RoutesBuilder createRouteBuilder() throws Exception { 
    return new RouteBuilder() { 
     @Override 
     public void configure() throws Exception { 
      SoapJaxbDataFormat df = createDataFormat(); 
      from("direct:start") // 
       .marshal(df) // 
       .to("mock:result"); 
     } 
    }; 
} 

メッセージがこのようなXMLでなければなりません:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope" xmlns:ns2="http://tempuri.org/"> 
    <Body> 
     <ns2:Add> 
      <ns2:intA>10</ns2:intA> 
      <ns2:intB>20</ns2:intB> 
     </ns2:Add> 
    </Body> 
</Envelope> 

(JAXB2プラグインによって生成された)POJOの対応以下を試してみてください、あなたのルートでそれを使用するには

package org.tempuri.calculator.jaxb2; 

import javax.xml.bind.annotation.XmlAccessType; 
import javax.xml.bind.annotation.XmlAccessorType; 
import javax.xml.bind.annotation.XmlRootElement; 
import javax.xml.bind.annotation.XmlType; 

@XmlAccessorType(XmlAccessType.FIELD) 
@XmlType(name = "", propOrder = { 
    "intA", 
    "intB" 
}) 
@XmlRootElement(name = "Add") 
public class Add { 

    protected int intA; 
    protected int intB; 

    public int getIntA() { 
     return intA; 
    } 

    public void setIntA(int value) { 
     this.intA = value; 
    } 

    public int getIntB() { 
     return intB; 
    } 

    public void setIntB(int value) { 
     this.intB = value; 
    } 

} 

あなたのpomファイルへ依存関係は:

<dependency> 
    <groupId>org.apache.camel</groupId> 
    <artifactId>camel-soap</artifactId> 
</dependency> 

この例で使用されるWSDL this unit testに基づいて、hereを見つけることができます。

関連する問題