3

Whenever i try to create a Webservice from a wsdl url i get an Error window in Netbeans IDE. Where there is no package or reference like this.

enter image description here

Here is my stack trace.

parsing WSDL...

[ERROR] A class/interface with the same name "org.wi.link.action.Exception" is already in use. Use a class customization to resolve this conflict. line 35 of file:/D:/Development/source/WebServiceProject/TestProject/src/conf/xml-resources/web-service-references/service/wsdl/urladdress/wionline/services/service.wsdl

[ERROR] (Relevant to above error) another "Exception" is generated from here. line 30 of file:/D:/Development/source/WebServiceProject/TestProject/src/conf/xml-resources/web-service-references/service/wsdl/urladdress/wionline/services/service.wsdl

[ERROR] Two declarations cause a collision in the ObjectFactory class. line 35 of file:/D:/Development/source/WebServiceProject/TestProject/src/conf/xml-resources/web-service-references/service/wsdl/urladdress/wionline/services/service.wsdl

[ERROR] (Related to above error) This is the other declaration.
line 30 of file:/D:/Development/source/WebServiceProject/TestProject/src/conf/xml-resources/web-service-references/service/wsdl/urladdress/wionline/services/service.wsdl

[ERROR] Two declarations cause a collision in the ObjectFactory class. line 38 of file:/D:/Development/source/WebServiceProject/TestProject/src/conf/xml-resources/web-service-references/service/wsdl/urladdress/wionline/services/service.wsdl

[ERROR] (Related to above error) This is the other declaration.
line 32 of file:/D:/Development/source/WebServiceProject/TestProject/src/conf/xml-resources/web-service-references/service/wsdl/urladdress/wionline/services/service.wsdl

D:\Development\source\WebServiceProject\TestProject\nbproject\jaxws-build.xml:225: wsimport failed BUILD FAILED (total time: 2 seconds)

I can also post jaxws-build.xml if required Thanks in advance.

GhousKhan22
  • 79
  • 1
  • 3
  • 10

2 Answers2

3

Under the hood wsimport utinilty uses JAXB compiler, so actualy error is relevant to JAXB. As stated in JAXB guide, you have two options - use schemabindings or factoryMethod customization, though that depends on your WSLD and it might be not possible. Another option would be to rename conflicting types in your WSDL document.

Based on comment below lets assume that this is your schema:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="Exception"> 
        <xs:sequence> 
            <xs:element minOccurs="0" name="Exception" nillable="true" type="xs:anyType"/>
        </xs:sequence>
    </xs:complexType> 
    <xs:element name="Exception"> 
        <xs:complexType> 
            <xs:sequence> 
                <xs:element minOccurs="0" name="Exception" nillable="true" type="Exception"/> 
            </xs:sequence> 
        </xs:complexType>
    </xs:element>
</xs:schema>

To gernerate same errors you might run xjc compiler:

/bin/xjc.sh schema.xsd

As mentioned above easyest way to fix this issue would be to rename complex type or element name. But to make things more interesting you might define JAXB customization

<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  version="1.0">
  <jaxb:bindings schemaLocation="schema.xsd">
    <jaxb:bindings node="//xs:complexType[@name='Exception']">
      <jaxb:factoryMethod name="TypeException"/>
      <jaxb:class name="TypeException" />
    </jaxb:bindings>
  </jaxb:bindings>
</jaxb:bindings>

And try once more:

/bin/xjc.sh -b binding.xml schema.xsd

Same binding might be supplied to wsimport utility:

wsimport myService.wsdl -b binding.xml
  • I have tried to create webservice client on a new project but the error remains the same :(. – GhousKhan22 Jan 02 '14 at 13:12
  • It might help if you could post at least parts of WSDL document relevant to your problem(lines 30-38). – Arunas Junevicius Jan 02 '14 at 13:46
  • parsing a schema... [ERROR] Content is not allowed in prolog. line 1 of file:/C:/Program%20Files/Java/jdk1.7.0_45/bin/Schema.xsd – GhousKhan22 Jan 03 '14 at 12:59
  • Solution to parser problem is probably defined [here](http://stackoverflow.com/questions/4569123/content-is-not-allowed-in-prolog-saxparserexception). Anyway I double checked it, xjc doesn't throw any unexpected errors and schema is just for illustrative purposes. How to configure NetBeans with WSDL and JAXB binding is described [here](https://netbeans.org/kb/docs/websvc/jaxb.html) – Arunas Junevicius Jan 06 '14 at 23:48
3

Webservice cannot be created with wsdl , only webservice client(to consume WS) can be created using wsdl.

For me the problem solved , by mistake i was adding "Web Service Client" with incorrect wsdl url , i was adding http://localhost:8080/MyService/MyService?Tester, which is the ws tester url.

The correct url should be the WSDL url i.e. http://localhost:8080/MyService/MyService?WSDL

Steps followed: 1. Go to Project-war 2. Right Click New > WebService Client 3. Select WSDL URL, paste the WSDL url , give package name

And its done :)

For me the problem solved .

You can only create WS from scratch or from existing bean.

Hope this will help you.

Bhumika
  • 169
  • 11
  • so you mean the webservices created/deployed in Netbeans6.1(with Glassfish2.1) cannot work fine in Netbeans 8.1(with Glassfish4.0)???? I have to create new webservice and paste all previous code in it but i cannot open the previous project directly and expect it to run smoothly..right?? – Maha Saad Jun 11 '20 at 09:39
  • I got this error when placing the wrong url when creating the web service client (the url except the '?wsdl' part). Your answer made me notice my mistake. – Broken_Window Aug 11 '20 at 00:48