简体   繁体   中英

How to use the SOAP service addSequence from WSO2 ESB 4.7

I'm trying to use the SOAP service addSequence from WSO2 ESB 4.7 I'm using the SequenceAdminService.wsdl file found at :

https://ip:9443/services/SequenceAdminService?wsdl

In this WSDL, the input parameter of the addSequence method has Object as type. I have a look to the server code, WSO2 ESB is attending a OMElement for the addSequence service.

So I added this dependency in my pom.xml :

<dependency>
  <groupId>org.apache.ws.commons.axiom.wso2</groupId>
  <artifactId>axiom</artifactId>
  <version>1.2.11.wso2v2</version>
</dependency>

And modified my code like this :

String sequenceXml = this.configTemplate.generateAuthentificationSequence(sequenceName, authorization);

OMElement sequenceElement = null;
try {
sequenceElement = AXIOMUtil.stringToOM(sequenceXml);

} catch (XMLStreamException e) {
    throw (new TechnicalException(e));             
}

try {               
    this.sequenceAdminStub.addSequence(sequenceElement);
} catch (SequenceAdminServiceSequenceEditorException e1) {
    throw (new TechnicalException(e1));
}

But at runtime, I get this Marshalling error :

javax.xml.ws.soap.SOAPFaultException: Marshalling Error: class org.apache.axiom.om.impl.llom.OMElementImpl nor any of its super class is known to this context.
   at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:594)
   at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:648)
   at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:152)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:157)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:189)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:316)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:323)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:72)
   at com.sun.xml.bind.v2.runtime.property.SingleReferenceNodeProperty.serializeBody(SingleReferenceNodeProperty.java:111)
   at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:340)
   at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:696)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:152)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:189)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:316)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:323)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:72)
   at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
   at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:315)
   at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:244)
   at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:95)
   at org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:550)
   at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:232)
   at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169)
   at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:110)
   at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
   at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
   at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:531)
   at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:461)
   at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:364)
   at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:317)
   at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:88)
   at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
   at com.sun.proxy.$Proxy55.addSequence(Unknown Source)
   at com.francetelecom.clara.cloud.iaas.wso2esb.infrastructure.Wso2SequenceAdapterImpl.createHttpAuthentSequence(Wso2SequenceAdapterImpl.java:117)
   at com.francetelecom.clara.cloud.iaas.wso2esb.infrastructure.Wso2SequenceAdapterIT.shouldCreateDeleteSequenceAuthent(Wso2SequenceAdapterIT.java:36)

Any idea ? Thanks

You can look at ESB code and see how it handles this.

save_sequence.jsp contains the code used when adding a sequence.

SequenceAdminClient.java

public void addSequence(SequenceMediator sequence) throws SequenceEditorException {
    OMElement sequenceElem = sequence.serialize(null);
    try {
        sequenceAdminStub.addSequence(sequenceElem);
    } catch (Exception e) {
        handleException("Error in adding the sequence with the configuration '"
                + sequenceElem + "'", e);
    }
}

SequenceMediator.java

public OMElement serialize(OMElement parent) {
    OMElement sequence = fac.createOMElement("sequence", synNS);
    if (!anonymous) {
        if (key != null) {
            // Use KeySerializer to serialize Key
            ValueSerializer keySerializer = new ValueSerializer();
            keySerializer.serializeValue(key, XMLConfigConstants.KEY, sequence);
        } else if (name != null) {
            sequence.addAttribute(fac.createOMAttribute(
                    "name", nullNS, name));

            if (errorHandler != null) {
                sequence.addAttribute(fac.createOMAttribute(
                        "onError", nullNS, errorHandler));
            }
            saveTracingState(sequence, this);
            serializeChildren(sequence, getList());
        }

        if (parent != null) {
            parent.addChild(sequence);
        }
    } else {
        if (errorHandler != null) {
            sequence.addAttribute(fac.createOMAttribute(
                    "onError", nullNS, errorHandler));
        }
        saveTracingState(sequence, this);
        serializeChildren(sequence, getList());
        if (parent != null) {
            parent.addChild(sequence);
        }
    }

    if (description != null) {

        OMElement descriptionElem = sequence.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "description"));

        if (descriptionElem != null) {
            descriptionElem.setText(description);
        } else {
            OMElement newDescriptionElem = fac.createOMElement("description", synNS);
            newDescriptionElem.setText(description);
            sequence.addChild(newDescriptionElem);
        }

    }

    return sequence;
}

All related files are at https://svn.wso2.org/repos/wso2/carbon/platform/branches/4.1.0/components/sequence-editor/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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