You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by pascale4 <pa...@inwind.it> on 2007/01/17 18:05:47 UTC

HTTPEndpoint overrideDefinition error?

Hi,
I defined a servicemix-assembly to access external web service through
servicemix-http (consumer-provider).
As you can see at this link :
http://www.nabble.com/Expose-external-web-service-with-http-component-%28very-simplified%29-tf3014055s12049.html
Note that xbean.xml of consumer doesn't contain soap="true" option.

When I download wsdl from http://localhost:8192/../main.wsdl I receive a
wsdl not complete. Then axis WSDL2Java class, create incomplete stub.
Debugging servicemix-http, I found that in HttpEndpoint.java
(ovverideDefinition method), when create wsdl doesn't add operations element
to binding section.
This is wsdl:binding part created :
<wsdl:binding name="HelloWorldEndpointConsumerBinding"
type="impl:HelloWorldService"></wsdl:binding>
and this is the right part would be created :
<wsdl:binding name="HelloWorldEndpointConsumerBinding"
type="impl:HelloWorldService">
<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
	<wsdl:operation name="echo">
<wsdlsoap:operation soapAction=""/>
	<wsdl:input name="echoRequest"><wsdlsoap:body use="literal"/></wsdl:input>
	<wsdl:output name="echoResponse"><wsdlsoap:body
use="literal"/></wsdl:output>
</wsdl:operation>
</wsdl:binding>

I modified HttpEndpoint.java source, and now it works fine. WSDL2Java create
correct stub.
Is it right? This is source I tested (backup your overrideDefinition in
HttpEndpoind.java and replace with this):
   protected void overrideDefinition(Definition def) throws Exception {
        PortType portType = getTargetPortType(def);
        if (portType != null) {
            QName[] names = (QName[])
def.getPortTypes().keySet().toArray(new QName[0]);
            for (int i = 0; i < names.length; i++) {
                if (!names[i].equals(portType.getQName())) {
                    def.removePortType(names[i]);
                }
            }
            names = (QName[]) def.getServices().keySet().toArray(new
QName[0]);
            for (int i = 0; i < names.length; i++) {
                def.removeService(names[i]);
            }
            names = (QName[]) def.getBindings().keySet().toArray(new
QName[0]);
            for (int i = 0; i < names.length; i++) {
                def.removeBinding(names[i]);
            }
            String location = getLocationURI();
            if (!location.endsWith("/")) {
                location += "/";
            }
            HttpLifeCycle lf = (HttpLifeCycle)
getServiceUnit().getComponent().getLifeCycle();
            if (lf.getConfiguration().isManaged()) {
                // TODO: need to find the port of the web server
                location = "http://localhost" +
lf.getConfiguration().getMapping() + new URI(location).getPath();
            }
            if
(portType.getQName().getNamespaceURI().equals(service.getNamespaceURI())) {
                if (isSoap()) {
                    PortTypeDecorator.decorate(
                            def,
                            portType,
                            location,
                            endpoint + "Binding",
                            service.getLocalPart(),
                            endpoint);
                    definition = def;
                } else {

        // Create binding
        Binding binding = def.createBinding();
        binding.setQName(new QName(service.getNamespaceURI(), endpoint +
"Binding"));
        binding.setPortType(portType);
        binding.setUndefined(false);
        // Create soap extension
        SOAPBinding soap = new SOAPBindingImpl();
        soap.setTransportURI("http://schemas.xmlsoap.org/soap/http");
        soap.setStyle("rpc");
        binding.addExtensibilityElement(soap);
        // Create operations
        List operations = portType.getOperations();
        for (Iterator iter = operations.iterator(); iter.hasNext();) {
            Operation operation = (Operation) iter.next();
            BindingOperation bindingOp = def.createBindingOperation();
            bindingOp.setName(operation.getName());
            SOAPOperation op = new SOAPOperationImpl();
            op.setSoapActionURI("");
            bindingOp.addExtensibilityElement(op);
            if (operation.getInput() != null) {
                BindingInput in = def.createBindingInput();
                in.setName(operation.getInput().getName());
                SOAPBody body = new SOAPBodyImpl();
                body.setUse("literal");
                in.addExtensibilityElement(body);
                bindingOp.setBindingInput(in);
            }
            if (operation.getOutput() != null) {
                BindingOutput out = def.createBindingOutput();
                out.setName(operation.getOutput().getName());
                SOAPBody body = new SOAPBodyImpl();
                body.setUse("literal");
                out.addExtensibilityElement(body);
                bindingOp.setBindingOutput(out);
            }
            for (Iterator itf = operation.getFaults().values().iterator();
itf.hasNext();) {
                Fault fault = (Fault) itf.next();
                BindingFault bindingFault = def.createBindingFault();
                bindingFault.setName(fault.getName());
                SOAPFault soapFault = new SOAPFaultImpl();
                soapFault.setUse("literal");
                soapFault.setName(fault.getName());
                bindingFault.addExtensibilityElement(soapFault);
                bindingOp.addBindingFault(bindingFault);
            }
            binding.addBindingOperation(bindingOp);
        }
        def.addBinding(binding);
        // Create service
        Port port = def.createPort();
        port.setName(endpoint);
        port.setBinding(binding);
        SOAPAddress address = new SOAPAddressImpl();
        address.setLocationURI(location);
        port.addExtensibilityElement(address);
        Service svc = def.createService();
        svc.setQName(service);
        svc.addPort(port);
        def.addService(svc);

/**
                    Binding binding = def.createBinding();
                    binding.setPortType(portType);
                    binding.setQName(new QName(service.getNamespaceURI(),
endpoint + "Binding"));
                    binding.setUndefined(false);
                    def.addBinding(binding);
*/
/**
                    Port port = def.createPort();
                    port.setName(endpoint);
                    port.setBinding(binding);
                    HTTPAddress address = new HTTPAddressImpl();
                    address.setLocationURI(location);
                    port.addExtensibilityElement(address);
                    def.addNamespace("wsdlsoap",
"http://schemas.xmlsoap.org/wsdl/http/");
                    Service svc = def.createService();
                    svc.setQName(service);
                    svc.addPort(port);
                    def.addService(svc);
*/
                    definition = def;
                }
            } else {
                definition = PortTypeDecorator.createImportDef(def,
service.getNamespaceURI(), "porttypedef.wsdl");
                PortTypeDecorator.decorate(
                        definition,
                        portType,
                        location,
                        endpoint + "Binding",
                        service.getLocalPart(),
                        endpoint);
            }
        }

    }


-- 
View this message in context: http://www.nabble.com/HTTPEndpoint-overrideDefinition-error--tf3028527s12049.html#a8414319
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: HTTPEndpoint overrideDefinition error?

Posted by pascale4 <pa...@inwind.it>.
Thaks for reply.
I attached complete application 
http://www.nabble.com/file/5692/helloworlds.zip helloworlds.zip 
As you suggest I tested with soap="true" and the WSDL created is complete
but not correct.
The style parameter of element wsdlsoap:binding comes with value "document".
The correct value would be "rpc". Is not?
However, if I test with "document" or "style" value, I receive this
exception :
     [java] AxisFault
     [java]  faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
     [java]  faultString:
     [java]  faultActor: null
     [java]  faultDetail:
     [java]     Envelope:
     [java]  <soapenv:Body>
     [java]   <soapenv:Fault>
     [java]    <faultcode
xmlns:ns1="http://xml.apache.org/axis/">ns1:Server.userException</faultcode>
     [java]    <faultstring>org.xml.sax.SAXException: Bad envelope tag: 
echo</faultstring>
     [java]    <detail>
     [java]     <ns2:stackTrace
xmlns:ns2="http://xml.apache.org/axis/">org.xml.sax.SAXException: Bad
envelope tag:  echo
     [java]     at
org.apache.axis.message.EnvelopeBuilder.startElement(EnvelopeBuilder.java:107)
     [java]     at
org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:906)
     [java]     at
org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
     [java]     at
org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown
Source)
     [java]     at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
Source)
     [java]     at
org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown
Source)
     [java]     at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
     [java]     at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
     [java]     at
org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
     [java]     at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown
Source)
     [java]     at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
     [java]     at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
Source)
     [java]     at javax.xml.parsers.SAXParser.parse(Unknown Source)
     [java]     at
org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:232)
     [java]     at
org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:546)
     [java]     at org.apache.axis.Message.getSOAPEnvelope(Message.java:377)
     [java]     at
org.apache.axis.handlers.soap.SOAPService$SOAPRequestHandler.invoke(SOAPService.java:176)
     [java]     at
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
     [java]     at
org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:156)
     [java]     at org.apache.axis.SimpleChain.invoke(SimpleChain.java:126)
     [java]     at
org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:437)
     [java]     at
org.apache.axis.server.AxisServer.invoke(AxisServer.java:316)
     [java]     at
org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:701)
     [java]     at
javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
     [java]     at
org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:335)
     [java]     at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     [java]     at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
     [java]     at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
     [java]     at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
     [java]     at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
     [java]     at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
     [java]     at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
     [java]     at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
     [java]     at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
     [java]     at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
     [java]     at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
     [java]     at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
     [java]     at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
     [java]     at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
     [java]     at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
     [java]     at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
     [java]     at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
     [java]     at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
     [java]     at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
     [java]     at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
     [java]     at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
     [java]     at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
     [java]     at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
     [java]     at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
     [java]     at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:193)
     [java]     at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
     [java]     at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
     [java]     at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:589)
     [java]     at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)
     [java]     at java.lang.Thread.run(Thread.java:595)
     [java] </ns2:stackTrace>
     [java]    </detail>
     [java]   </soapenv:Fault>
     [java]  </soapenv:Body>


gnodet wrote:
> 
> I think the problem comes from the fact that you forgot the
>   soap=true attribute on the <http:endpoint /> definition.
> The code will use the PortTypeDecorator to create the binding
> if your endpoint is soap-enabled, and this one will create all the
> needed operations.
> 

-- 
View this message in context: http://www.nabble.com/HTTPEndpoint-overrideDefinition-error--tf3028527s12049.html#a8427006
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: HTTPEndpoint overrideDefinition error?

Posted by Guillaume Nodet <gn...@gmail.com>.
I think the problem comes from the fact that you forgot the
  soap=true attribute on the <http:endpoint /> definition.
The code will use the PortTypeDecorator to create the binding
if your endpoint is soap-enabled, and this one will create all the
needed operations.

On 1/17/07, pascale4 <pa...@inwind.it> wrote:
>
> Hi,
> I defined a servicemix-assembly to access external web service through
> servicemix-http (consumer-provider).
> As you can see at this link :
> http://www.nabble.com/Expose-external-web-service-with-http-component-%28very-simplified%29-tf3014055s12049.html
> Note that xbean.xml of consumer doesn't contain soap="true" option.
>
> When I download wsdl from http://localhost:8192/../main.wsdl I receive a
> wsdl not complete. Then axis WSDL2Java class, create incomplete stub.
> Debugging servicemix-http, I found that in HttpEndpoint.java
> (ovverideDefinition method), when create wsdl doesn't add operations element
> to binding section.
> This is wsdl:binding part created :
> <wsdl:binding name="HelloWorldEndpointConsumerBinding"
> type="impl:HelloWorldService"></wsdl:binding>
> and this is the right part would be created :
> <wsdl:binding name="HelloWorldEndpointConsumerBinding"
> type="impl:HelloWorldService">
> <wsdlsoap:binding style="rpc"
> transport="http://schemas.xmlsoap.org/soap/http"/>
>         <wsdl:operation name="echo">
> <wsdlsoap:operation soapAction=""/>
>         <wsdl:input name="echoRequest"><wsdlsoap:body use="literal"/></wsdl:input>
>         <wsdl:output name="echoResponse"><wsdlsoap:body
> use="literal"/></wsdl:output>
> </wsdl:operation>
> </wsdl:binding>
>
> I modified HttpEndpoint.java source, and now it works fine. WSDL2Java create
> correct stub.
> Is it right? This is source I tested (backup your overrideDefinition in
> HttpEndpoind.java and replace with this):
>    protected void overrideDefinition(Definition def) throws Exception {
>         PortType portType = getTargetPortType(def);
>         if (portType != null) {
>             QName[] names = (QName[])
> def.getPortTypes().keySet().toArray(new QName[0]);
>             for (int i = 0; i < names.length; i++) {
>                 if (!names[i].equals(portType.getQName())) {
>                     def.removePortType(names[i]);
>                 }
>             }
>             names = (QName[]) def.getServices().keySet().toArray(new
> QName[0]);
>             for (int i = 0; i < names.length; i++) {
>                 def.removeService(names[i]);
>             }
>             names = (QName[]) def.getBindings().keySet().toArray(new
> QName[0]);
>             for (int i = 0; i < names.length; i++) {
>                 def.removeBinding(names[i]);
>             }
>             String location = getLocationURI();
>             if (!location.endsWith("/")) {
>                 location += "/";
>             }
>             HttpLifeCycle lf = (HttpLifeCycle)
> getServiceUnit().getComponent().getLifeCycle();
>             if (lf.getConfiguration().isManaged()) {
>                 // TODO: need to find the port of the web server
>                 location = "http://localhost" +
> lf.getConfiguration().getMapping() + new URI(location).getPath();
>             }
>             if
> (portType.getQName().getNamespaceURI().equals(service.getNamespaceURI())) {
>                 if (isSoap()) {
>                     PortTypeDecorator.decorate(
>                             def,
>                             portType,
>                             location,
>                             endpoint + "Binding",
>                             service.getLocalPart(),
>                             endpoint);
>                     definition = def;
>                 } else {
>
>         // Create binding
>         Binding binding = def.createBinding();
>         binding.setQName(new QName(service.getNamespaceURI(), endpoint +
> "Binding"));
>         binding.setPortType(portType);
>         binding.setUndefined(false);
>         // Create soap extension
>         SOAPBinding soap = new SOAPBindingImpl();
>         soap.setTransportURI("http://schemas.xmlsoap.org/soap/http");
>         soap.setStyle("rpc");
>         binding.addExtensibilityElement(soap);
>         // Create operations
>         List operations = portType.getOperations();
>         for (Iterator iter = operations.iterator(); iter.hasNext();) {
>             Operation operation = (Operation) iter.next();
>             BindingOperation bindingOp = def.createBindingOperation();
>             bindingOp.setName(operation.getName());
>             SOAPOperation op = new SOAPOperationImpl();
>             op.setSoapActionURI("");
>             bindingOp.addExtensibilityElement(op);
>             if (operation.getInput() != null) {
>                 BindingInput in = def.createBindingInput();
>                 in.setName(operation.getInput().getName());
>                 SOAPBody body = new SOAPBodyImpl();
>                 body.setUse("literal");
>                 in.addExtensibilityElement(body);
>                 bindingOp.setBindingInput(in);
>             }
>             if (operation.getOutput() != null) {
>                 BindingOutput out = def.createBindingOutput();
>                 out.setName(operation.getOutput().getName());
>                 SOAPBody body = new SOAPBodyImpl();
>                 body.setUse("literal");
>                 out.addExtensibilityElement(body);
>                 bindingOp.setBindingOutput(out);
>             }
>             for (Iterator itf = operation.getFaults().values().iterator();
> itf.hasNext();) {
>                 Fault fault = (Fault) itf.next();
>                 BindingFault bindingFault = def.createBindingFault();
>                 bindingFault.setName(fault.getName());
>                 SOAPFault soapFault = new SOAPFaultImpl();
>                 soapFault.setUse("literal");
>                 soapFault.setName(fault.getName());
>                 bindingFault.addExtensibilityElement(soapFault);
>                 bindingOp.addBindingFault(bindingFault);
>             }
>             binding.addBindingOperation(bindingOp);
>         }
>         def.addBinding(binding);
>         // Create service
>         Port port = def.createPort();
>         port.setName(endpoint);
>         port.setBinding(binding);
>         SOAPAddress address = new SOAPAddressImpl();
>         address.setLocationURI(location);
>         port.addExtensibilityElement(address);
>         Service svc = def.createService();
>         svc.setQName(service);
>         svc.addPort(port);
>         def.addService(svc);
>
> /**
>                     Binding binding = def.createBinding();
>                     binding.setPortType(portType);
>                     binding.setQName(new QName(service.getNamespaceURI(),
> endpoint + "Binding"));
>                     binding.setUndefined(false);
>                     def.addBinding(binding);
> */
> /**
>                     Port port = def.createPort();
>                     port.setName(endpoint);
>                     port.setBinding(binding);
>                     HTTPAddress address = new HTTPAddressImpl();
>                     address.setLocationURI(location);
>                     port.addExtensibilityElement(address);
>                     def.addNamespace("wsdlsoap",
> "http://schemas.xmlsoap.org/wsdl/http/");
>                     Service svc = def.createService();
>                     svc.setQName(service);
>                     svc.addPort(port);
>                     def.addService(svc);
> */
>                     definition = def;
>                 }
>             } else {
>                 definition = PortTypeDecorator.createImportDef(def,
> service.getNamespaceURI(), "porttypedef.wsdl");
>                 PortTypeDecorator.decorate(
>                         definition,
>                         portType,
>                         location,
>                         endpoint + "Binding",
>                         service.getLocalPart(),
>                         endpoint);
>             }
>         }
>
>     }
>
>
> --
> View this message in context: http://www.nabble.com/HTTPEndpoint-overrideDefinition-error--tf3028527s12049.html#a8414319
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet
------------------------
Architect, LogicBlaze (http://www.logicblaze.com/)
Blog: http://gnodet.blogspot.com/