java WSDL parsing

using WSDLreader and other javax.wsdl classes how can I read complex types' definitions.
Who is Participating?
benchpresserConnect With a Mentor Author Commented: libraries are helpful. now we are trying to implement the solution.
benchpresserAuthor Commented:

now i m using wsdl4j api, and reading operations, but i can not access complextypes and function parameters which are complextype. Here is my code.

I must read whole structure of defined complex types, and function signs to entegrate our own programming language to any web service. briefly, i need to write a tool like wsimport for a custom programming language.

import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.wsdl.Binding;
import javax.wsdl.Definition;
import javax.wsdl.Operation;
import javax.wsdl.Port;
import javax.wsdl.PortType;
import javax.wsdl.Service;
import javax.wsdl.WSDLException;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;

public class Application {

	 * @param args
	public static void main(String[] args) {

		try {
			WSDLFactory factory = WSDLFactory.newInstance();
			WSDLReader reader = factory.newWSDLReader();
			reader.setFeature("javax.wsdl.verbose", false);
			reader.setFeature("javax.wsdl.importDocuments", true);
			Definition def = reader.readWSDL(null, "");
			def = reader.readWSDL(null, "");

			Map services = def.getServices();
			Iterator servicesIterator = services.values().iterator();

			Map messages = def.getMessages();
			/*Iterator messagesIterator = messages.values().iterator();
			while (messagesIterator.hasNext()) {
				MessageImpl mess = (MessageImpl);
			} */

			while (servicesIterator.hasNext()) {
				Service service = (Service);

				Map ports = service.getPorts();
				Iterator portsIterator = ports.keySet().iterator();


				while (portsIterator.hasNext()) {
					String strPort =;

					Port port = service.getPort(strPort);
					Binding binding = port.getBinding();
					PortType portType = binding.getPortType();

					List operations = portType.getOperations();
					Iterator opIterator = operations.iterator();
					while (opIterator.hasNext()) {
						Operation operation = (Operation);
						if (!operation.isUndefined()) {

							// read input
							Map params = operation.getInput().getMessage().getParts();
							Iterator paramsIterator = params.keySet().iterator();

							int n = 1;

							StringBuffer sbParams = new StringBuffer();
							while (paramsIterator.hasNext()) {

								PartImpl iParam = (PartImpl) params.get(;
								if (iParam.getTypeName() == null) {
									sbParams.append(iParam.getElementName().getLocalPart()).append(" p").append(n).append(",");
								} else if (iParam.getElementName() == null) {
									sbParams.append(iParam.getTypeName().getLocalPart()).append(" ").append(iParam.getName()).append(", ");
								} else {
									System.err.println("sicis .:.");

							if (sbParams.length() > 0) {
								sbParams.delete(sbParams.length() - 1, sbParams.length());

							// read output

							Map output = operation.getOutput().getMessage().getParts();
							Iterator outputIterator = output.keySet().iterator();
							String strOutput = "";
							while (outputIterator.hasNext()) {

								PartImpl iOutput = (PartImpl) output.get(;
								if (iOutput.getTypeName() == null) {
									strOutput = iOutput.getElementName().getLocalPart();
								} else if (iOutput.getElementName() == null) {
									strOutput = iOutput.getTypeName().getLocalPart();
								} else {
									System.err.println("sicis .:.");

							StringBuffer sb = new StringBuffer(strOutput).append(" ").append(operation.getName()).append("(").append(sbParams).append(")");
							System.out.println("   " + sb.toString());
		} catch (WSDLException e) {

Open in new window

Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.


Well, that sounds like a tough task

Perhaps you saw the references below:

this paper suggests to use StAX to parse WSDL with custom types:

maybe this could be of some help:
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
Apache Woden is a good choice:

And this Easy WSDL from OW2 guys is easy to use :
benchpresserAuthor Commented:
my answer is the best and solves the problem
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.