You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Deyan Popov <de...@gmail.com> on 2009/04/30 10:45:35 UTC

How to turn off stdout messages when using WSDL 2.0 ?

Axis2 writes to stdout when using WSDL 2.0 and I cannot find a way to turn
it off. When some of the namespace URIs inside the WSDL 2.0 document are not
accessible, I see warning messages like:
    Woden[Warning],0:0,Description-1001,The targetNamespace '
http://www.example.org/simple_doc/' is not dereferencable.

I am using Axis2 inside a larger application, which uses stdout for its own
purposes. The messages from Axis2 look completely out of place on the
console. Redirecting the stdout stream of the Java process is not an option.
Also I have no control over the WSDL files that may be passed to the
application, so I cannot "fix" all namespace URIs.

These messages seem to come from the Apache Woden library and are not
written via Log4j. According to the Woden User Guide there is a default
ErrorHandler which writes to stdout and that ErrorHandler can be replaced.
But I don't see how this can be done via the Axis2 API - in particular the
org.apache.axis2.description.WSDL20ToAllAxisServicesBuilder class.

Does anyone know how to silence these stdout messages ?


Here are a simple Java program and a WSDL 2.0 file that demonstrate the
problem:

import java.io.File;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.util.List;
import org.apache.axis2.description.WSDL20ToAllAxisServicesBuilder;


public class WSDL20Experiment {

    public static void main(String[] args) throws Exception {
        createAllAxisServicesFromWSDL20File("simple_doc_wsdl20.wsdl",
false);
    }

    public static List createAllAxisServicesFromWSDL20File(String wsdl,
            boolean isServerSide) throws Exception {

        URL wsdlURL;
        File wsdlFile = new File(wsdl);
        if (wsdlFile.exists()) {
            wsdlURL = wsdlFile.toURL();
        } else {
            wsdlURL = new URL(wsdl);
        }
        URI wsdlURI = new URI(wsdlURL.getProtocol(), wsdlURL.getUserInfo(),
                wsdlURL.getHost(), wsdlURL.getPort(), wsdlURL.getPath(),
                wsdlURL.getQuery(), wsdlURL.getRef());

        InputStream inp = wsdlURL.openStream();
        List services;
        try {
            WSDL20ToAllAxisServicesBuilder wsdlToAxisServiceBuilder = new
WSDL20ToAllAxisServicesBuilder(inp);
            wsdlToAxisServiceBuilder.setBaseUri(wsdlURI.toASCIIString());
            wsdlToAxisServiceBuilder.setServerSide(isServerSide);
            services = wsdlToAxisServiceBuilder.populateAllServices();
        } finally {
            if (inp != null) {
                inp.close();
            }
        }

        return services;
    }

}

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<description xmlns="http://www.w3.org/ns/wsdl" xmlns:tns="
http://www.example.org/simple_doc/" xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/" name="simple_doc_wsdl20" targetNamespace="
http://www.example.org/simple_doc/" xmlns:wsoap="
http://www.w3.org/ns/wsdl/soap">

  <types>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/simple_doc/">
      <xsd:element name="name" type="xsd:string" />
      <xsd:element name="age" type="xsd:int" />
    </xsd:schema>
  </types>

  <interface name="simple_doc_wsdl20">
    <operation name="getAge" pattern="http://www.w3.org/ns/wsdl/in-out">
      <input messageLabel="In" element="tns:name"/>
      <output messageLabel="Out" element="tns:age"/>
    </operation>
  </interface>

  <binding name="simple_doc_wsdl20SOAP11" interface="tns:simple_doc_wsdl20"
type="http://www.w3.org/ns/wsdl/soap" wsoap:version="1.1" wsoap:protocol="
http://www.w3.org/2003/05/soap/bindings/HTTP">
        <operation ref="tns:getAge" wsoap:action="urn:getAge"/>
  </binding>

  <service name="simple_doc_wsdl20" interface="tns:simple_doc_wsdl20">
    <endpoint name="simple_doc_wsdl20_endpoint"
              binding="tns:simple_doc_wsdl20SOAP11"
              address="http://localhost:9998"/>
  </service>

</description>

Re: How to turn off stdout messages when using WSDL 2.0 ?

Posted by Deyan Popov <de...@gmail.com>.
I just opened a JIRA bug for the Axis2 project:
https://issues.apache.org/jira/browse/AXIS2-4334.

Re: How to turn off stdout messages when using WSDL 2.0 ?

Posted by Sagara Gunathunga <sa...@gmail.com>.
Hi Jeremy,

> Since Woden is a utility and is therefore always going to be used in
> the context of something else (like Axis2) then whatever the logging
> strategy we'll need to direct Woden logging / tracing to an arbitrary
> logging mechanism. SLF4J seems to be popular and doesn't suffer the
> classloader issues of JCL (apparently although I haven't gone into
> it).
>

+1 for this ,

My intention was to emphasize the usage of any logging framework for
this scenario , as you proposed with SLF4J users can plug there
convenient longing framework in their end and seems like SLF4J  is the
best way to handle this.

Thanks,

-- 
Sagara Gunathunga

Blog - http://ssagara.blogspot.com
Web - http://sagaras.awardspace.com/

Re: How to turn off stdout messages when using WSDL 2.0 ?

Posted by Jeremy Hughes <hu...@apache.org>.
Hi Sagara,

2009/5/1 Sagara Gunathunga <sa...@gmail.com>
>
> Hi Jeremy ,
> BTW in Woden ErrorHandlerImpl we used S.O.P statements to handle
> warnings/errors/fatalErrors , but if we use a logging framework (such
> as log4j) to handle those stuff instead of S.O.P statements , users
> can control it using logging configuration and no need to implement
> custom error handlers.

Yes, my thoughts entirely.

>
> I think we have to think about such improvement in Woden side too. We
> already have a JIRA issue related to logging [1]  , Any way we can
> discuss this matter further in Woden -dev list .

Since Woden is a utility and is therefore always going to be used in
the context of something else (like Axis2) then whatever the logging
strategy we'll need to direct Woden logging / tracing to an arbitrary
logging mechanism. SLF4J seems to be popular and doesn't suffer the
classloader issues of JCL (apparently although I haven't gone into
it).

>
>
> [1] - http://issues.apache.org/jira/browse/WODEN-71

Re: How to turn off stdout messages when using WSDL 2.0 ?

Posted by Sagara Gunathunga <sa...@gmail.com>.
Hi Jeremy ,
BTW in Woden ErrorHandlerImpl we used S.O.P statements to handle
warnings/errors/fatalErrors , but if we use a logging framework (such
as log4j) to handle those stuff instead of S.O.P statements , users
can control it using logging configuration and no need to implement
custom error handlers.

I think we have to think about such improvement in Woden side too. We
already have a JIRA issue related to logging [1]  , Any way we can
discuss this matter further in Woden -dev list .


[1] - http://issues.apache.org/jira/browse/WODEN-71

Thanks ,

-- 
Sagara Gunathunga

Blog - http://ssagara.blogspot.com
Web - http://sagaras.awardspace.com/

Re: How to turn off stdout messages when using WSDL 2.0 ?

Posted by Jeremy Hughes <hu...@apache.org>.
Deyan, I agree these leakages to stdout should stop. The way to set the
error handler is by doing:

WSDLReader.getErrorReporter().setErrorHandler(customErrorHandler)

but like you say, the WSDLReader is hidden inside the
WSDL20ToAxisServiceBuilder. Since this class uses the commons-logging Log
class to output warnings/errors etc already, then I feel it should provide a
custom error handler to Woden so its output goes to wherever commons-logging
is configured to send its output. Would this solve the problem for you?

So I think you have a genuine issue. Please would you open a JIRA:
https://issues.apache.org/jira/browse/AXIS2

btw: you need a JIRA ID in case you don't already have an ID.

Jeremy

2009/4/30 Deyan Popov <de...@gmail.com>

> Axis2 writes to stdout when using WSDL 2.0 and I cannot find a way to turn
> it off. When some of the namespace URIs inside the WSDL 2.0 document are not
> accessible, I see warning messages like:
>     Woden[Warning],0:0,Description-1001,The targetNamespace '
> http://www.example.org/simple_doc/' is not dereferencable.
>
> I am using Axis2 inside a larger application, which uses stdout for its own
> purposes. The messages from Axis2 look completely out of place on the
> console. Redirecting the stdout stream of the Java process is not an option.
> Also I have no control over the WSDL files that may be passed to the
> application, so I cannot "fix" all namespace URIs.
>
> These messages seem to come from the Apache Woden library and are not
> written via Log4j. According to the Woden User Guide there is a default
> ErrorHandler which writes to stdout and that ErrorHandler can be replaced.
> But I don't see how this can be done via the Axis2 API - in particular the
> org.apache.axis2.description.WSDL20ToAllAxisServicesBuilder class.
>
> Does anyone know how to silence these stdout messages ?
>
>
> Here are a simple Java program and a WSDL 2.0 file that demonstrate the
> problem:
>
> import java.io.File;
> import java.io.InputStream;
> import java.net.URI;
> import java.net.URL;
> import java.util.List;
> import org.apache.axis2.description.WSDL20ToAllAxisServicesBuilder;
>
>
> public class WSDL20Experiment {
>
>     public static void main(String[] args) throws Exception {
>         createAllAxisServicesFromWSDL20File("simple_doc_wsdl20.wsdl",
> false);
>     }
>
>     public static List createAllAxisServicesFromWSDL20File(String wsdl,
>             boolean isServerSide) throws Exception {
>
>         URL wsdlURL;
>         File wsdlFile = new File(wsdl);
>         if (wsdlFile.exists()) {
>             wsdlURL = wsdlFile.toURL();
>         } else {
>             wsdlURL = new URL(wsdl);
>         }
>         URI wsdlURI = new URI(wsdlURL.getProtocol(), wsdlURL.getUserInfo(),
>                 wsdlURL.getHost(), wsdlURL.getPort(), wsdlURL.getPath(),
>                 wsdlURL.getQuery(), wsdlURL.getRef());
>
>         InputStream inp = wsdlURL.openStream();
>         List services;
>         try {
>             WSDL20ToAllAxisServicesBuilder wsdlToAxisServiceBuilder = new
> WSDL20ToAllAxisServicesBuilder(inp);
>             wsdlToAxisServiceBuilder.setBaseUri(wsdlURI.toASCIIString());
>             wsdlToAxisServiceBuilder.setServerSide(isServerSide);
>             services = wsdlToAxisServiceBuilder.populateAllServices();
>         } finally {
>             if (inp != null) {
>                 inp.close();
>             }
>         }
>
>         return services;
>     }
>
> }
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <description xmlns="http://www.w3.org/ns/wsdl" xmlns:tns="
> http://www.example.org/simple_doc/" xmlns:wsdl="
> http://schemas.xmlsoap.org/wsdl/" name="simple_doc_wsdl20"
> targetNamespace="http://www.example.org/simple_doc/" xmlns:wsoap="
> http://www.w3.org/ns/wsdl/soap">
>
>   <types>
>     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.example.org/simple_doc/">
>       <xsd:element name="name" type="xsd:string" />
>       <xsd:element name="age" type="xsd:int" />
>     </xsd:schema>
>   </types>
>
>   <interface name="simple_doc_wsdl20">
>     <operation name="getAge" pattern="http://www.w3.org/ns/wsdl/in-out">
>       <input messageLabel="In" element="tns:name"/>
>       <output messageLabel="Out" element="tns:age"/>
>     </operation>
>   </interface>
>
>   <binding name="simple_doc_wsdl20SOAP11" interface="tns:simple_doc_wsdl20"
> type="http://www.w3.org/ns/wsdl/soap" wsoap:version="1.1" wsoap:protocol="
> http://www.w3.org/2003/05/soap/bindings/HTTP">
>         <operation ref="tns:getAge" wsoap:action="urn:getAge"/>
>   </binding>
>
>   <service name="simple_doc_wsdl20" interface="tns:simple_doc_wsdl20">
>     <endpoint name="simple_doc_wsdl20_endpoint"
>               binding="tns:simple_doc_wsdl20SOAP11"
>               address="http://localhost:9998"/>
>   </service>
>
> </description>
>