Hello,
I am trying to run wsdl2java against my WSDL, but I am getting this error:
WSDLException (at /wsdl:definitions/types): faultCode=INVALID_WSDL:
Encountered illegal extension element 'types' in the context of a
'javax.wsdl.Definition'. Extension elements must be in a namespace
other than WSDL's.:
at com.ibm.wsdl.xml.WSDLReaderImpl.parseExtensibilityElement(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at
org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:516)
at
org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:495)
at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:361)
at java.lang.Thread.run(Unknown Source)
Any idea what causes this problem? I am using a very basic service
and the WSDL is generated by axis. Here is my WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
xmlns:impl="http://localhost/axis/services/MyService"
xmlns:intf="http://localhost/axis/services/MyService"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns1="urn:MyService"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://localhost/axis/services/MyService">
<!--WSDL created by Apache Axis version: 1.2.1
Built on Jun 14, 2005 (09:15:57 EDT)-->
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:MyService">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="MyBean">
<sequence>
<element name="name" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</schema>
</types>
<wsdl:message name="getMyBeanResponse">
<wsdl:part name="getMyBeanReturn" type="tns1:MyBean"/>
</wsdl:message>
<wsdl:message name="getMyBeanRequest">
</wsdl:message>
<wsdl:portType name="MyService">
<wsdl:operation name="getMyBean">
<wsdl:input name="getMyBeanRequest" message="impl:getMyBeanRequest"/>
<wsdl:output name="getMyBeanResponse"
message="impl:getMyBeanResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MyServiceSoapBinding" type="impl:MyService">
<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getMyBean">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getMyBeanRequest">
<wsdlsoap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://paulbarry.com"/>
</wsdl:input>
<wsdl:output name="getMyBeanResponse">
<wsdlsoap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost/axis/services/MyService"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MyServiceService">
<wsdl:port name="MyService" binding="impl:MyServiceSoapBinding">
<wsdlsoap:address location="http://localhost/axis/services/MyService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
The classes involved are very basic. I have this bean:
package com.paulbarry;
public class MyBean {
private String name;
public MyBean() {}
public MyBean(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
And this service:
package com.paulbarry;
public class MyService {
public MyBean getMyBean() {
return new MyBean("My Bean");
}
}
I have this client, which works perfectly fine:
package com.paulbarry;
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
public class MyClient {
public static void main(String[] args) throws Exception {
String endpoint =
"http://localhost/axis/services/MyService";
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName(new QName("getMyBean") );
QName qn = new QName("urn:MyService","MyBean");
call.registerTypeMapping(MyBean.class, qn,
new BeanSerializerFactory(MyBean.class, qn),
new BeanDeserializerFactory(MyBean.class, qn));
call.setReturnType(qn);
MyBean bean = (MyBean)call.invoke(new Object[] {});
System.out.println(bean.getName());
}
}
And here is my deployment descriptor:
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="MyService" provider="java:RPC">
<parameter name="className" value="com.paulbarry.MyService"/>
<parameter name="allowedMethods" value="*"/>
<beanMapping qname="myNS:MyBean" xmlns:myNS="urn:MyService"
languageSpecificType="java:com.paulbarry.MyBean"/>
</service>
</deployment>