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 <[email protected]>

> 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>
>

Reply via email to