WSDL Tutorials - Herong's Tutorial Examples - Version 2.03, by Dr. Herong Yang
ServiceClient Class Loading WSDL 2.0 Documents
This section provides a test program to load WSDL 2.0 document with Axis2 1.4.1 ServicClient class. The loading failed, because the constructor is expecting WSDL 1.1 document by default.
According to the manual, Java Axis2 1.4.1 ServicClient class seems to support WSDL 2.0. See the comment on the portName parameter of the constructor method:
public ServiceClient(ConfigurationContext configContext, java.net.URL wsdlURL, QName wsdlServiceName, java.lang.String portName) throws AxisFault Create a service client for WSDL service identified by the QName of the wsdl:service element in a WSDL document. Parameters: configContext - The configuration context under which this service lives (may be null, in which case a new local one will be created) wsdlURL - The URL of the WSDL document to read wsdlServiceName - The QName of the WSDL service in the WSDL document to create a client for portName - The name of the WSDL 1.1 port to create a client for. May be null (if WSDL 2.0 is used or if only one port is there).
Here is test program, Axis2ServiceClientHelloWsdl20.java, that loads my WSDL 2.0 document, Hello_WSDL_20_SOAP.wsdl
/** * Axis2ServiceClientHelloWsdl20.java * Copyright (c) 2009 by Dr. Herong Yang, herongyang.com * All rights reserved */ import java.io.PrintStream; import java.net.URL; import javax.xml.namespace.QName; import org.apache.axis2.client.ServiceClient; import org.apache.axis2.context.ConfigurationContext; class Axis2ServiceClientHelloWsdl20 { public static void main(String[] args) { PrintStream out = System.out; // Setting initial values ConfigurationContext config = null; String wsdl = "file:///C:/herong/Hello_WSDL_20_SOAP.wsdl"; String tns = "http://www.herongyang.com/Service/"; String serviceName = "helloService"; String portName = null; try { // Creating a dynamic service client with a given WSDL ServiceClient client = new ServiceClient( config, new URL(wsdl), new QName(tns, serviceName), portName); } catch (Exception e) { e.printStackTrace(); } } }
But it failed to execute:
C:\herong>\local\jdk\bin\java -Djava.ext.dirs=\local\axis2\lib\ Axis2ServiceClientHelloWsdl20 org.apache.axis2.AxisFault: WSDLException (at /wsdl:description): faultCode=INVALID_WSDL: Expected element '{http://schemas.xmlsoap.org/wsdl/}definitions'. at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430) at org.apache.axis2.description.AxisService.createClientSideAxi... at org.apache.axis2.client.ServiceClient.<init>(ServiceClient.j... at Axis2ServiceClientHelloWsdl20.main(Axis2ServiceClientHelloWs... Caused by: javax.wsdl.WSDLException: WSDLException (at /wsdl:descr... at com.ibm.wsdl.xml.WSDLReaderImpl.checkElementName(Unknown Sou... at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Sou... at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
The ServiceClient constructor method is expecting a WSDL 1.1 document by default. I could not find a way to change this default behavior.
Last update: 2009.
Table of Contents
WSDL 2.0 Document Structure and Syntax
WSDL Version 2.0 Part 2: Adjuncts
WSDL 2.0 Document Examples with SOAP Binding
►WSDL 20 Programming APIs and Testing Tools
►ServiceClient Class Loading WSDL 2.0 Documents
WSDL2Java Converting WSDL 2.0 Documents to Stub Classes
WSDL 2.0 Component Model - Test
WSDL 1.1 Document Structure and Syntax
WSDL 1.1 Binding Extension for SOAP 1.1
soapUI 3.0.1 - Web Service Testing Tool
WSDL 1.1 and SOAP 1.1 Examples - Document and RPC Styles
PHP SOAP Extension in PHP 5.3.1
Using WSDL in Perl with SOAP::Lite 0.710
Using WSDL Document in Java with Axis2 1.4.1
Using WSDL2Java to Generate Web Service Stub Classes
WSDL 1.1 Binding Extension for SOAP 1.2
WSDL 1.1 and SOAP 1.2 Examples - Document and RPC Styles