function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
malmmalm 

JAX-WS wsimport tool does not compile enterprise.wsdl

I am trying to get my enterprise.wsdl to compile with the wsimport tool from the latest JAX-WS release. Basically what I am trying to do is to eventually move our application away from the now pretty tired Axis 1 environment to JAX-WS which will in due course come bundled with Java 1.6.

Typical errors are like:

 [wsimport] [ERROR] A class/interface with the same name "com.sforce.soap.enterprise.DescribeLayout" is already in use. Use a class customization to resolve this conflict.
 [wsimport]   line 2611 of file:/home/mm/oscar/build_current/dev/jaxws/sforce/enterprise.wsdl

 [wsimport] [ERROR] (Relevant to above error) another "DescribeLayout" is generated from here.
 [wsimport]   line 2456 of file:/home/mm/oscar/build_current/dev/jaxws/sforce/enterprise.wsdl

It seems wsimport which I believe internally uses the xjc compiler from JAXB doesn't like identical element and type names.

Have others encountered the same / similar problem? Are there simple solutions (I know I can create custom bindings for those elements but that is pretty painful)?

Thanks
SuperfellSuperfell
You can log bugs for JAX-WS folks to fix their buggy tools. (if the tired 5 year old axis 1.1 can handle this, the shiney new jax-ws tool shouldn't be barfing).
malmmalm
Not sure its quite as simple as claiming its a bug in JAX-WS. It seems to me, although I am no expert on this, that its the JAXB spec which drives this.  JAXB requires a class to be generated for each element and each named complex type (among many other things). In the SalesForce WSDL a number of times element and complex type names are identical. This leads to the problem observed. So custom JAXB bindings seem to be the only way to resolve this.

I guess this problem will not go away and if more developers adopt JAXB, JAX-WS with the release of Java 1.6 this question will be asked again.
SuperfellSuperfell
I guess i'm unclear on what you're looking for, JAXB didn't exist when the first cut of our WSDL was done. We can't possibly be compatible with every random subset of XML Schema that people dream up in the future.

If you're finding JAXB to be unsuitable for your real world use cases, then it would seem to me that your gripe should be directed at the JAXB folks.
dapkusdapkus
Just to let you know, we've contacted Sun about the issue.    If you'd like to provide feedback to Sun on the issue, here are the relevant links:

Discussion forum:
http://forums.java.net/jive/forum.jspa?forumID=46=0

IssueTracker:
http://jax-ws.dev.java.net/servlets/ProjectIssues

Mailing list:
users@jax-ws.dev.java.net

-Pete
malmmalm
So did I: http://forums.java.net/jive/thread.jspa?threadID=20858

I managed to get the WSDL compiled using JAXB bindings. I may publish the details here later once its stable for the benefits(?) of other developers.

There are however at least two other issues with JAX-WS and sforce I haven't got to the bottom yet.

1) sforce seems to expect a SOAPAction header looking like
     SOAPAction: ""
    However, JAX-WS sends
     SOAPAction:
    Note the missing quotes! I have reported this under: http://forums.java.net/jive/thread.jspa?threadID=20913 although I am not sure 'who is right', i.e. how this should be set based on the WSDL defining action="".

2) Your wsdl uses the <soap:header ../> feature in its operation definitions heavily to maintain the session information. wsimport does not seem to create the appropiate parameters for this on the generated methods. Haven't got to investigate this to any depth yet and therefore I have not reported it (yet).
    

malmmalm
Simon,

what I am looking for is a meaningful discussion on a technical issue. I was not asking for sforce to change it wsdl. I thought this was a sforce developer community discussion board where Java sforce developers can raise and discuss technical issues they encounter. Just because I encountered a problem in what I was doing and asked here if others encountered similar issues doesn't mean I blame sforce for the problem or expect sforce to have ready made solutions.

Manuel
malmmalm
Got it working with JAX-WS 2.1 latest nightly (not EA3!).

1) Compile the enterprise.wsdl with a JAX-WS/JAXB bindings customisation file similar to:
Code:
<bindings
    wsdlLocation="enterprise.wsdl"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="http://java.sun.com/xml/ns/jaxws">
    <bindings node="//xsd:schema[@targetNamespace='urn:sobject.enterprise.soap.sforce.com']">
      <jaxb:globalBindings underscoreBinding="asCharInWord"/>
      <jaxb:schemaBindings>
        <jaxb:nameXmlTransform>
          <jaxb:typeName suffix="Type" />
        </jaxb:nameXmlTransform>
      </jaxb:schemaBindings>
    </bindings>
    <enableWrapperStyle>false</enableWrapperStyle>
    <enableAsyncMapping>false</enableAsyncMapping>
</bindings>

2) Use code similar to this to log in and set the soap session header:
Code:
            service = new SforceService();
            port = service.getSoap();
            WSBindingProvider bp = (WSBindingProvider)port;

            Login parameters = new Login();
            parameters.setUsername(...);
            parameters.setPassword(...);
            LoginResponse loginReponse = port.login(parameters);

            String url = loginReponse.getResult().getServerUrl();
            Map<String, Object> rc = bp.getRequestContext();
            rc.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);

            SessionHeader sh = new com.sforce.soap.enterprise.ObjectFactory().createSessionHeader();
            sh.setSessionId(loginReponse.getResult().getSessionId());

            JAXBContext jc = JAXBContext.newInstance("com.sforce.soap.enterprise");
            bp.setOutboundHeaders(Headers.create((JAXBRIContext)jc, sh));
Hope this helps someone else down the track.

Manuel
adamgadamg
Great! Glad to hear you got this working, and thanks for sharing the code.
Zahid.ShaikhZahid.Shaikh

I tried to use "MyEclipse" to generate "client stub" using XFire(Right click on wsdl->MyEclipse->New Web Service Client) and it did not work.

I was able to get it working in MyEclipse by using Axis 1.3(right click on the wsdl->Web Service->Generate Client)

LemonGrassLemonGrass
Thanks for this Solution, was having trouble with the same thing myself until I found your post. I can also confirm that when you change the Target Namespace in the binding file it will work fine with the Partner.wsdl, and also can be built with the JAX-WS Maven plugin on Java.Net. 
care.comcare.com
It still doesn't work for me:

bin\wsimport.bat enterprise.wsdl -b enterprise.xjb

parsing WSDL...


[WARNING] src-resolve: Cannot resolve the name 'tns:ID' to a(n) 'type definition' component.
line 28 of file:/C:/work/incubator/salesForceExampleJAXBEnterprise/Enterprise/enterprise.wsdl#type
s?schema1

[ERROR] A class/interface with the same name "com.sforce.soap.enterprise.DescribeLayout" is already
in use. Use a class customization to resolve this conflict.
line 3289 of file:/C:/work/incubator/salesForceExampleJAXBEnterprise/Enterprise/enterprise.wsdl

[ERROR] (Relevant to above error) another "DescribeLayout" is generated from here.
line 3088 of file:/C:/work/incubator/salesForceExampleJAXBEnterprise/Enterprise/enterprise.wsdl

[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 3289 of file:/C:/work/incubator/salesForceExampleJAXBEnterprise/Enterprise/enterprise.wsdl

[ERROR] (Related to above error) This is the other declaration.
line 3088 of file:/C:/work/incubator/salesForceExampleJAXBEnterprise/Enterprise/enterprise.wsdl
care.comcare.com
I got it working with the following (note the difference in @targetNamespace):

wsdlLocation="enterprise.wsdl"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://java.sun.com/xml/ns/jaxws">








false
false
care.comcare.com
oops..  here is the binding file that works:

<bindings
    wsdlLocation="enterprise.wsdl"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="http://java.sun.com/xml/ns/jaxws">
    <bindings node="//xsd:schema[@targetNamespace='urn:enterprise.soap.sforce.com']">
      <jaxb:globalBindings underscoreBinding="asCharInWord"/>
      <jaxb:schemaBindings>
        <jaxb:nameXmlTransform>
        <jaxb:typeName suffix="Type"/>
        </jaxb:nameXmlTransform>
      </jaxb:schemaBindings>
    </bindings>
    <enableWrapperStyle>false</enableWrapperStyle>
    <enableAsyncMapping>false</enableAsyncMapping>
</bindings>
 
Ezio_2010Ezio_2010

Still getting [WARNING] src-resolve: Cannot resolve the name 'ens:sObject' to a(n) 'type definition' component.

 

 

any help? Im using this...

 

<bindings
    wsdlLocation="enterprise.wsdl"
  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns="http://java.sun.com/xml/ns/jaxws">
  <bindings
    node="//xsd:schema[@targetNamespace='urn:partner.soap.sforce.com']">
    <jaxb:globalBindings
      underscoreBinding="asCharInWord" />
    <jaxb:schemaBindings>
      <jaxb:nameXmlTransform>
        <jaxb:typeName
          suffix="Type" />
      </jaxb:nameXmlTransform>
    </jaxb:schemaBindings>
  </bindings>
  <enableWrapperStyle>false</enableWrapperStyle>
  <enableAsyncMapping>false</enableAsyncMapping>
</bindings>

 

 

just as u did!!!!

YAYA

I ran into same issue while generating the client code using JAX-WS.

 

I could successfully generatthe client code using Axis... but I need it with JAX-WS.. any help  ???

 

Thanks,

Stevano CheungStevano Cheung

Basically i searched around and was able to solve the errormessages when generating the stubs using wsimport. For details see below from fellow developers. Hope this helps.

 

wsimport

wsimport -version: JAX-WS RI 2.1.6 in JDK 6


Problem where warning occurs.

Bug.
ID Warning:
https://jax-ws.dev.java.net/issues/show_bug.cgi?id=844

 

SalesForce compatibility:
https://jax-ws.dev.java.net/issues/show_bug.cgi?id=228

 

Solution:
http://stackoverflow.com/questions/785945/problem-generating-java-soap-web-services-client-with-jdk-tool-wsimport-from-a-ws

 

Syntax example( which was working for me, where the "generated" option is the directory for the stubs):
wsimport -B-XautoNameResolution -d generated -keep partner.wsdl