質問

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.

役に立ちましたか?

解決 2

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

他のヒント

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top