You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Thorsten Kitz (JIRA)" <ji...@apache.org> on 2017/03/09 08:57:38 UTC

[jira] [Updated] (AXIS2-5840) http-Transport: Request for static WSDL does not work with syntax "serviceName?wsdl"

     [ https://issues.apache.org/jira/browse/AXIS2-5840?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thorsten Kitz updated AXIS2-5840:
---------------------------------
    Description: 
Since we upgraded our Axis2 framework from version 1.5.x to 1.7.4 it is no longer possible to get a *static* WSDL using the syntax <ServiceURL>?wsdl. Regardless of the location of the wsdl-file itself, the returned message is either an error text or a generated wsdl by Axis2 (if you turn the "useOriginalwsdl" parameter in the services.xml file to false). The cause of the bug is somewhere either in the AxisServlet or in the AxisService classes.

First the request executes the AxisServlet.doGet(HttpServletRequest request,
HttpServletResponse response) class:

{code:java}
... starting line number 275 ...
        if ((query != null) && new QueryStringParser(query).search(metadataQueryParamNames)) {
            // handling meta data exchange stuff
            agent.processListService(request, response);
        } else if (HttpUtils.endsWithIgnoreCase(requestURI , ".xsd") ||
                HttpUtils.endsWithIgnoreCase(requestURI, ".wsdl")) {
            agent.processExplicitSchemaAndWSDL(request, response);
...
{code}

The "metadataQueryParameterNames" are ["wsdl","xsl","wsdl2","policy"], so the first if-branch is taken (unless you write <service-URL>/service-name.wsdl, then the first else statement is taken). The following code fragment is in the class ListingAgent (starting line 297):

{code:java}
    private void handleWSDLRequest(HttpServletRequest req,
                                   HttpServletResponse res,
                                   String url,
                                   AxisService axisService) throws IOException {
        if (!canExposeServiceMetadata(axisService)){
            res.sendError(HttpServletResponse.SC_FORBIDDEN);
            return;
        }
        OutputStream out = res.getOutputStream();
        res.setContentType("text/xml");
        String ip = extractHost(url);
        String wsdlName = getParamtereIgnoreCase(req , "wsdl");

        if (wsdlName != null && wsdlName.length()>0) {
            axisService.printUserWSDL(out, wsdlName, ip);
        } else {
            axisService.printWSDL(out, ip);
        }
    }
{code}

Since there is no "wsdlName" in the GET-request, the else branch calls the 2 parameter "printWSDL" method in the AxisService class:

{code:java}
	public void printWSDL(OutputStream out, String requestIP) throws AxisFault {
		// If we're looking for pre-existing WSDL, use that.
		if (isUseUserWSDL()) {
			printUserWSDL(out, null, requestIP);
			return;
		}
...
{code}

"useOriginalwsdl" is a parameter in the services.xml and is set to "true", therefor

{code:java}
	public void printUserWSDL(OutputStream out, String wsdlName, String ip)
			throws AxisFault {
		Definition definition = null;
		// first find the correct wsdl definition
		Parameter wsdlParameter = getParameter(WSDLConstants.WSDL_4_J_DEFINITION);
		if (wsdlParameter != null) {
			definition = (Definition) wsdlParameter.getValue();
		}

		if (definition != null) {
			try {
				printDefinitionObject(getWSDLDefinition(definition, wsdlName),
						out, ip);
			} catch (WSDLException e) {
				throw AxisFault.makeFault(e);
			}
		} else {
			printWSDLError(out);
		}

	}
{code}

is called. 

There seems to be no way, that

{code:java}
getParameter(WSDLConstants.WSDL_4_J_DEFINITION)
{code}

ever returns a not null "Parameter object" in this scenario, therefor the "printWSDLError()" is called and the error message is returned to the caller.

This bug is easily reproducable in any scenario.


  was:
Since we upgraded our Axis2 framework from version 1.5.x to 1.7.4 it is no longer possible to get a *static* WSDL using the syntax <ServiceURL>?wsdl. Regardless of the location of the wsdl-file itself, the returned message is either an error text or a generated wsdl by Axis2 (if you turn the "useOriginalwsdl" parameter in the services.xml file to true). The cause of the bug is somewhere either in the AxisServlet or in the AxisService classes.

First the request executes the AxisServlet.doGet(HttpServletRequest request,
HttpServletResponse response) class:

{code:java}
... starting line number 275 ...
        if ((query != null) && new QueryStringParser(query).search(metadataQueryParamNames)) {
            // handling meta data exchange stuff
            agent.processListService(request, response);
        } else if (HttpUtils.endsWithIgnoreCase(requestURI , ".xsd") ||
                HttpUtils.endsWithIgnoreCase(requestURI, ".wsdl")) {
            agent.processExplicitSchemaAndWSDL(request, response);
...
{code}

The "metadataQueryParameterNames" are ["wsdl","xsl","wsdl2","policy"], so the first if-branch is taken (unless you write <service-URL>/service-name.wsdl, then the first else statement is taken). The following code fragment is in the class ListingAgent (starting line 297):

{code:java}
    private void handleWSDLRequest(HttpServletRequest req,
                                   HttpServletResponse res,
                                   String url,
                                   AxisService axisService) throws IOException {
        if (!canExposeServiceMetadata(axisService)){
            res.sendError(HttpServletResponse.SC_FORBIDDEN);
            return;
        }
        OutputStream out = res.getOutputStream();
        res.setContentType("text/xml");
        String ip = extractHost(url);
        String wsdlName = getParamtereIgnoreCase(req , "wsdl");

        if (wsdlName != null && wsdlName.length()>0) {
            axisService.printUserWSDL(out, wsdlName, ip);
        } else {
            axisService.printWSDL(out, ip);
        }
    }
{code}

Since there is no "wsdlName" in the GET-request, the else branch calls the 2 parameter "printWSDL" method in the AxisService class:

{code:java}
	public void printWSDL(OutputStream out, String requestIP) throws AxisFault {
		// If we're looking for pre-existing WSDL, use that.
		if (isUseUserWSDL()) {
			printUserWSDL(out, null, requestIP);
			return;
		}
...
{code}

"useOriginalwsdl" is a parameter in the services.xml and is set to "true", therefor

{code:java}
	public void printUserWSDL(OutputStream out, String wsdlName, String ip)
			throws AxisFault {
		Definition definition = null;
		// first find the correct wsdl definition
		Parameter wsdlParameter = getParameter(WSDLConstants.WSDL_4_J_DEFINITION);
		if (wsdlParameter != null) {
			definition = (Definition) wsdlParameter.getValue();
		}

		if (definition != null) {
			try {
				printDefinitionObject(getWSDLDefinition(definition, wsdlName),
						out, ip);
			} catch (WSDLException e) {
				throw AxisFault.makeFault(e);
			}
		} else {
			printWSDLError(out);
		}

	}
{code}

is called. 

There seems to be no way, that

{code:java}
getParameter(WSDLConstants.WSDL_4_J_DEFINITION)
{code}

ever returns a not null "Parameter object" in this scenario, therefor the "printWSDLError()" is called and the error message is returned to the caller.

This bug is easily reproducable in any scenario.



> http-Transport: Request  for static WSDL does not work with syntax "serviceName?wsdl"
> -------------------------------------------------------------------------------------
>
>                 Key: AXIS2-5840
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5840
>             Project: Axis2
>          Issue Type: Bug
>          Components: transports
>    Affects Versions: 1.7.4
>            Reporter: Thorsten Kitz
>            Priority: Minor
>
> Since we upgraded our Axis2 framework from version 1.5.x to 1.7.4 it is no longer possible to get a *static* WSDL using the syntax <ServiceURL>?wsdl. Regardless of the location of the wsdl-file itself, the returned message is either an error text or a generated wsdl by Axis2 (if you turn the "useOriginalwsdl" parameter in the services.xml file to false). The cause of the bug is somewhere either in the AxisServlet or in the AxisService classes.
> First the request executes the AxisServlet.doGet(HttpServletRequest request,
> HttpServletResponse response) class:
> {code:java}
> ... starting line number 275 ...
>         if ((query != null) && new QueryStringParser(query).search(metadataQueryParamNames)) {
>             // handling meta data exchange stuff
>             agent.processListService(request, response);
>         } else if (HttpUtils.endsWithIgnoreCase(requestURI , ".xsd") ||
>                 HttpUtils.endsWithIgnoreCase(requestURI, ".wsdl")) {
>             agent.processExplicitSchemaAndWSDL(request, response);
> ...
> {code}
> The "metadataQueryParameterNames" are ["wsdl","xsl","wsdl2","policy"], so the first if-branch is taken (unless you write <service-URL>/service-name.wsdl, then the first else statement is taken). The following code fragment is in the class ListingAgent (starting line 297):
> {code:java}
>     private void handleWSDLRequest(HttpServletRequest req,
>                                    HttpServletResponse res,
>                                    String url,
>                                    AxisService axisService) throws IOException {
>         if (!canExposeServiceMetadata(axisService)){
>             res.sendError(HttpServletResponse.SC_FORBIDDEN);
>             return;
>         }
>         OutputStream out = res.getOutputStream();
>         res.setContentType("text/xml");
>         String ip = extractHost(url);
>         String wsdlName = getParamtereIgnoreCase(req , "wsdl");
>         if (wsdlName != null && wsdlName.length()>0) {
>             axisService.printUserWSDL(out, wsdlName, ip);
>         } else {
>             axisService.printWSDL(out, ip);
>         }
>     }
> {code}
> Since there is no "wsdlName" in the GET-request, the else branch calls the 2 parameter "printWSDL" method in the AxisService class:
> {code:java}
> 	public void printWSDL(OutputStream out, String requestIP) throws AxisFault {
> 		// If we're looking for pre-existing WSDL, use that.
> 		if (isUseUserWSDL()) {
> 			printUserWSDL(out, null, requestIP);
> 			return;
> 		}
> ...
> {code}
> "useOriginalwsdl" is a parameter in the services.xml and is set to "true", therefor
> {code:java}
> 	public void printUserWSDL(OutputStream out, String wsdlName, String ip)
> 			throws AxisFault {
> 		Definition definition = null;
> 		// first find the correct wsdl definition
> 		Parameter wsdlParameter = getParameter(WSDLConstants.WSDL_4_J_DEFINITION);
> 		if (wsdlParameter != null) {
> 			definition = (Definition) wsdlParameter.getValue();
> 		}
> 		if (definition != null) {
> 			try {
> 				printDefinitionObject(getWSDLDefinition(definition, wsdlName),
> 						out, ip);
> 			} catch (WSDLException e) {
> 				throw AxisFault.makeFault(e);
> 			}
> 		} else {
> 			printWSDLError(out);
> 		}
> 	}
> {code}
> is called. 
> There seems to be no way, that
> {code:java}
> getParameter(WSDLConstants.WSDL_4_J_DEFINITION)
> {code}
> ever returns a not null "Parameter object" in this scenario, therefor the "printWSDLError()" is called and the error message is returned to the caller.
> This bug is easily reproducable in any scenario.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org