无法使用TransformMessage组件在Mule中转换消息

时间:2016-04-07 13:43:07

标签: java xml wsdl mule esb

我无法使用转换消息转换消息。我的输入是一个java对象,按照wsdl输出,输出是application / xml。

Request is Object的格式为:

/**
 * PackagingRequest.java
 *
 * This file was auto-generated from WSDL
 * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
 */

package packaging;

public class PackagingRequest  implements java.io.Serializable {
    private java.lang.String packagingProduct;

    private java.lang.String packagingID;

    private java.lang.String packagingRequiredDate;

    public PackagingRequest() {
    }

    public PackagingRequest(
           java.lang.String packagingProduct,
           java.lang.String packagingID,
           java.lang.String packagingRequiredDate) {
           this.packagingProduct = packagingProduct;
           this.packagingID = packagingID;
           this.packagingRequiredDate = packagingRequiredDate;
    }


    /**
     * Gets the packagingProduct value for this PackagingRequest.
     * 
     * @return packagingProduct
     */
    public java.lang.String getPackagingProduct() {
        return packagingProduct;
    }


    /**
     * Sets the packagingProduct value for this PackagingRequest.
     * 
     * @param packagingProduct
     */
    public void setPackagingProduct(java.lang.String packagingProduct) {
        this.packagingProduct = packagingProduct;
    }


    /**
     * Gets the packagingID value for this PackagingRequest.
     * 
     * @return packagingID
     */
    public java.lang.String getPackagingID() {
        return packagingID;
    }


    /**
     * Sets the packagingID value for this PackagingRequest.
     * 
     * @param packagingID
     */
    public void setPackagingID(java.lang.String packagingID) {
        this.packagingID = packagingID;
    }


    /**
     * Gets the packagingRequiredDate value for this PackagingRequest.
     * 
     * @return packagingRequiredDate
     */
    public java.lang.String getPackagingRequiredDate() {
        return packagingRequiredDate;
    }


    /**
     * Sets the packagingRequiredDate value for this PackagingRequest.
     * 
     * @param packagingRequiredDate
     */
    public void setPackagingRequiredDate(java.lang.String packagingRequiredDate) {
        this.packagingRequiredDate = packagingRequiredDate;
    }

    private java.lang.Object __equalsCalc = null;
    public synchronized boolean equals(java.lang.Object obj) {
        if (!(obj instanceof PackagingRequest)) return false;
        PackagingRequest other = (PackagingRequest) obj;
        if (obj == null) return false;
        if (this == obj) return true;
        if (__equalsCalc != null) {
            return (__equalsCalc == obj);
        }
        __equalsCalc = obj;
        boolean _equals;
        _equals = true && 
            ((this.packagingProduct==null && other.getPackagingProduct()==null) || 
             (this.packagingProduct!=null &&
              this.packagingProduct.equals(other.getPackagingProduct()))) &&
            ((this.packagingID==null && other.getPackagingID()==null) || 
             (this.packagingID!=null &&
              this.packagingID.equals(other.getPackagingID()))) &&
            ((this.packagingRequiredDate==null && other.getPackagingRequiredDate()==null) || 
             (this.packagingRequiredDate!=null &&
              this.packagingRequiredDate.equals(other.getPackagingRequiredDate())));
        __equalsCalc = null;
        return _equals;
    }

    private boolean __hashCodeCalc = false;
    public synchronized int hashCode() {
        if (__hashCodeCalc) {
            return 0;
        }
        __hashCodeCalc = true;
        int _hashCode = 1;
        if (getPackagingProduct() != null) {
            _hashCode += getPackagingProduct().hashCode();
        }
        if (getPackagingID() != null) {
            _hashCode += getPackagingID().hashCode();
        }
        if (getPackagingRequiredDate() != null) {
            _hashCode += getPackagingRequiredDate().hashCode();
        }
        __hashCodeCalc = false;
        return _hashCode;
    }

    // Type metadata
    private static org.apache.axis.description.TypeDesc typeDesc =
        new org.apache.axis.description.TypeDesc(PackagingRequest.class, true);

    static {
        typeDesc.setXmlType(new javax.xml.namespace.QName("http://www.example.org/Packaging/", "PackagingRequest"));
        org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
        elemField.setFieldName("packagingProduct");
        elemField.setXmlName(new javax.xml.namespace.QName("", "PackagingProduct"));
        elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
        elemField.setNillable(false);
        typeDesc.addFieldDesc(elemField);
        elemField = new org.apache.axis.description.ElementDesc();
        elemField.setFieldName("packagingID");
        elemField.setXmlName(new javax.xml.namespace.QName("", "PackagingID"));
        elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
        elemField.setNillable(false);
        typeDesc.addFieldDesc(elemField);
        elemField = new org.apache.axis.description.ElementDesc();
        elemField.setFieldName("packagingRequiredDate");
        elemField.setXmlName(new javax.xml.namespace.QName("", "PackagingRequiredDate"));
        elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
        elemField.setNillable(false);
        typeDesc.addFieldDesc(elemField);
    }

    /**
     * Return type metadata object
     */
    public static org.apache.axis.description.TypeDesc getTypeDesc() {
        return typeDesc;
    }

    /**
     * Get Custom Serializer
     */
    public static org.apache.axis.encoding.Serializer getSerializer(
           java.lang.String mechType, 
           java.lang.Class _javaType,  
           javax.xml.namespace.QName _xmlType) {
        return 
          new  org.apache.axis.encoding.ser.BeanSerializer(
            _javaType, _xmlType, typeDesc);
    }

    /**
     * Get Custom Deserializer
     */
    public static org.apache.axis.encoding.Deserializer getDeserializer(
           java.lang.String mechType, 
           java.lang.Class _javaType,  
           javax.xml.namespace.QName _xmlType) {
        return 
          new  org.apache.axis.encoding.ser.BeanDeserializer(
            _javaType, _xmlType, typeDesc);
    }

}

我的骡子流如下:     

<mule xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:ws="http://www.mulesoft.org/schema/mule/ws" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
    <ws:consumer-config name="Web_Service_Consumer" wsdlLocation="wsdl/PackagingSOAP.wsdl" service="Packaging" port="PackagingSOAP" serviceAddress="http://localhost:8080/PackagingProject/services/PackagingSOAP" doc:name="Web Service Consumer"/>
    <flow name="testing_enricher_webserviceFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/testingenricher" doc:name="HTTP"/>
        <logger message="Welcome to the enricher flow.....a packaging service will be called now , " level="INFO" doc:name="Logger"/>
        <component class="testingmulefacets.PackagingList" doc:name="Java"/>
        <custom-transformer mimeType="application/xml" class="testingmulefacets.TransformList" doc:name="Java"/>
        <logger message="payload before transform #[payload]" level="INFO" doc:name="Logger"/>
        <dw:transform-message metadata:id="4a89ba40-6031-4bd8-a515-e09b03a9a1b7" doc:name="Transform Message">
            <dw:set-payload><![CDATA[%dw 1.0
%output application/xml
%namespace ns0 http://www.example.org/Packaging/
---
{



    ns0#PackagingType: {




        PackagingProduct: payload.packagingProduct,



        PackagingID: payload.packagingID

,

        PackagingRequiredDate: payload.packagingRequiredDate
    }
}]]></dw:set-payload>
        </dw:transform-message>
        <logger message="payload after transform #[payload]" level="INFO" doc:name="Logger"/>
        <ws:consumer config-ref="Web_Service_Consumer" operation="NewOperation" doc:name="Web Service Consumer"/>
    </flow>
</mule>

当我这样做时,我在prolog中得到了一个错误,意思是'p'(代码112)。预期'&lt;'  at [row,col {unknown-source}]:[1,1](com.ctc.wstx.exc.WstxUnexpectedCharException)

我注意到Transform消息的输出是com.mulesoft.weave.mule.WeaveMessageProcessor$WeaveOutputHandler@19e422ef,而不是预期的xml,但输入正确是RequestPackaging Object。

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

  

当我这样做时,我在prolog中得到了一个错误,意思是'p'(代码112)。预期'&lt;' at [row,col {unknown-source}]:[1,1](com.ctc.wstx.exc.WstxUnexpectedCharException)

输入xml格式错误。如错误所述,它不以<开头。您需要jaxb-to-xml-transformer结帐

https://docs.mulesoft.com/mule-user-guide/v/3.7/jaxb-transformers

Mule JAXB Object to XML Transformer throwing JAXBException