The Source for Java Technology Collaboration
User: Password:



Vivek Pandey

Vivek Pandey's Blog

How to deal with unresolved xs:schema references in WSDL

Posted by vivekp on May 25, 2007 at 11:45 PM | Comments (10)

I have been thinking of writing this blog for quite sometime to the benefit of those who have been having troubles importing WSDLs that references xs:schema but do not have corresponding import for such entities. This causes wsimport tool to report error. Mark from portal team reported the same issue while importing Share Point services and also WSIT and other users have reported the similar problems.

So this is what happens, when wsimport is run on a WSDL that references xs:schema and does not provide a corresponding import:

wsimport  SecureConversation.wsdl

Gives the following error:

[ERROR] undefined element declaration 'xs:schema'
line 1 of http://131.107.72.15/Security_WsSecurity_Service_Indigo/WSSecureConversation.svc?xsd=xsd0

To fix this, you would do two things

  • Run wsimport with -b option and pass the URL of XML Schema. This is to take care of missing import.
  • There are potential name conflicts in schema for schema. this was discussed here at length and Kohsuke has provided a JAXB customization to resolve such conflicts.

So your wsimport command will be

wsimport -b  http://www.w3.org/2001/XMLSchema.xsd  -b  customization.xjb  SecureConversation.wsdl

You can do the same with NB 5.5.1, you would need to provide local copies of these schema and customization files. If you are facing this issue try it and let us know if you see any issue.


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • hi, sorry to bother, but I'm using the netbeans 5.5 wizard to create a webservice client from a wsdl which i think was created in .net framework. So, this webservice belongs to ActivPlant, a program which is installed in another computer of my network, and I'm trying to invoke it using the wizard, but when i do it it gives me back this error: wsimport-client-clean-ApReporting.asmx: init: wsimport-init: wsimport-client-check-ApReporting.asmx: wsimport-client-ApReporting.asmx: warning: src-resolve: Cannot resolve the name 's:schema' to a(n) 'element declaration' component. line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: undefined element declaration 's:schema' line 0 of file:/C:/Documents%20and%20Settings/Administrator/JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl#types?schema1 error: org.netbeans.core.execution.ExitSecurityException: Exit from within execution engine, normal org.netbeans.core.execution.ExitSecurityException: Exit from within execution engine, normal at org.netbeans.core.execution.SecMan.checkExitImpl(SecMan.java:60) at org.netbeans.core.execution.SecMan$PrivilegedCheck.run(SecMan.java:129) at java.security.AccessController.doPrivileged(Native Method) at org.netbeans.core.execution.SecMan$PrivilegedCheck.check(SecMan.java:144) at org.netbeans.core.execution.SecMan$PrivilegedCheck.checkExit(SecMan.java:139) at org.netbeans.core.execution.SecMan.checkExit(SecMan.java:44) at org.netbeans.TopSecurityManager.checkExit(TopSecurityManager.java:104) at java.lang.Runtime.exit(Runtime.java:88) at java.lang.System.exit(System.java:906) at com.sun.tools.ws.processor.modeler.wsdl.JAXBModelBuilder.bind(JAXBModelBuilder.java:126) at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.buildJAXBModel(WSDLModeler.java:2204) at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.internalBuildModel(WSDLModeler.java:221) at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLModeler.java:178) at com.sun.tools.ws.processor.config.ModelInfo.buildModel(ModelInfo.java:85) at com.sun.tools.ws.processor.Processor.runModeler(Processor.java:79) at com.sun.tools.ws.wscompile.CompileTool.run(CompileTool.java:541) at com.sun.tools.ws.util.ToolBase.run(ToolBase.java:54) at com.sun.tools.ws.ant.WsImport.execute(WsImport.java:417) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) at org.apache.tools.ant.Project.executeTarget(Project.java:1185) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) at org.apache.tools.ant.Project.executeTargets(Project.java:1068) at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:240) at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:293) at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:131) Command invoked: wsimport "C:\Program Files\Java\jdk1.6.0_02\jre\bin\java.exe" -d "C:\Documents and Settings\Administrator\JavaApplication4\build\generated\wsimport\binaries" -keep -s "C:\Documents and Settings\Administrator\JavaApplication4\build\generated\wsimport\client" -catalog "C:\Documents and Settings\Administrator\JavaApplication4\catalog.xml" "C:\Documents and Settings\Administrator\JavaApplication4/xml-resources/web-service-references/ApReporting.asmx/wsdl/ap5mpr/Activplant/ApReportService/ApReporting.asmx.wsdl" -p javaapplication4.newpackage -wsdllocation http://ap5mpr/Activplant/ApReportService/ApReporting.asmx?WSDL C:\Documents and Settings\Administrator\JavaApplication4\nbproject\build-impl.xml:264: wsimport failed could somebody tell me please how to make it work using the wizard? i need this webservice client working in a few days, and I barely know anything about java language or methods, so if any of you know how to make it work it would be of great help. Thanks.

    Posted by: marcelman on August 09, 2007 at 12:52 PM

  • With NB 5.5.1 it is little complicated. Here are the steps, I will add them in the user's guide:

    1. Download http://www.w3.org/2001/XMLSchema.xsd as XMLSchema.xml and edit it to change the reference of XMLSchema.dtd to http://www.w3.org/2001/XMLSchema.dtd

    2. Download jaxb customization file http://weblogs.java.net/blog/kohsuke/archive/20070228/xsd.xjb as xsd.xml (the renaming to .xml is required as NB's WSDL customization editor does not allow adding any other file type as customization file).

    3.Open 'Edit Web Services Attributes Window' and go to WSDL config tab. Scroll all the way to bottom and add the above 2 files.

    4. Now refresh the Web Services Refernece.

    Posted by: vivekp on August 15, 2007 at 03:58 PM

  • Hi!, thank you for the answer. I did as you told me, saved the XMLSchema as a .xml and replace the reference to XMLSchema.dtd to http://www.w3.org/2001/XMLSchema.dtd in the doc type declaration line (line7 if I remember well), and saved the other file as a .xml. I added the two to the web reference, but the errors are still the same. Any idea why this is happening?. Thanks

    Posted by: marcelman on August 16, 2007 at 08:14 AM

  • Just as a experiment, I tested the web service on C#, it worked out just well, but when I tested on J# the compiler threw me back errors. Could it be that (i'm getting the service from a partner software development company) whoever programmed the web service did it in a way that it has a bug or something and it can't be accessed from java? thanks. (If you want, I can publish here the specific .wsdl that is generating these troubles)

    Posted by: marcelman on August 16, 2007 at 11:23 AM

  • It is always better to bring this kind of discussion to the forum at: http://forums.java.net/jive/forum.jspa?forumID=46&start=0. You can provide more details on what kind of error you are getting etc.

    Posted by: vivekp on August 16, 2007 at 12:08 PM

  • Above is very specific to NB. Can you tell us what needs to be done to run wsimport ant task with bindings ?

    Posted by: jumanji on August 24, 2007 at 09:42 AM

  • Hi, I am using the following wsdl and schema which have been generated by the wsgen ant task from the metro-pack. The return type and the input paramter for my web service were xjc generated classes based on a previously defined schema. I have been able to successfully war the service up and run it in my local tomcat instance. However, when I run the wsimport I get error. Following are the wsdl and the schemas referenced there: WSDL: - - - - - - - - - - - - - - - - - xsd 1: - - - - - - - - - - - - xsd2: - - - - - - - - - - - - xsd3: - - - - - - - - - - - - - - - - - - Here is the wsimport error I am getting: Buildfile: C:\workspace\SAMS-TTS-Java-WS\build.xml wsimport: [wsimport] Consider using / so that wsimport won't do unnecessary compilation [wsimport] command line: wsimport -d C:\workspace\SAMS-TTS-Java-WS\classes -keep -s C:\workspace\SAMS-TTS-Java-WS\src -verbose http://localhost:8080/sams-tts-webservice/getNetworkAbuseTicketList?wsdl -p com.comcast.cable.sams.tts.wsclient.jaxws [wsimport] parsing WSDL... [wsimport] [WARNING] src-resolve: Cannot resolve the name 'ns1:Header' to a(n) 'element declaration' component. [wsimport] line 16 of http://localhost:8080/sams-tts-webservice/getNetworkAbuseTicketList?xsd=1 [wsimport] [WARNING] src-resolve: Cannot resolve the name 'ns1:Body' to a(n) 'element declaration' component. [wsimport] line 17 of http://localhost:8080/sams-tts-webservice/getNetworkAbuseTicketList?xsd=1 [wsimport] [WARNING] src-resolve: Cannot resolve the name 'ns2:Header' to a(n) 'element declaration' component. [wsimport] line 29 of http://localhost:8080/sams-tts-webservice/getNetworkAbuseTicketList?xsd=1 [wsimport] [WARNING] src-resolve: Cannot resolve the name 'ns2:Body' to a(n) 'element declaration' component. [wsimport] line 30 of http://localhost:8080/sams-tts-webservice/getNetworkAbuseTicketList?xsd=1 [wsimport] [ERROR] undefined element declaration 'ns1:Header' [wsimport] line 16 of http://localhost:8080/sams-tts-webservice/getNetworkAbuseTicketList?xsd=1 [wsimport] [ERROR] undefined element declaration 'ns1:Body' [wsimport] line 17 of http://localhost:8080/sams-tts-webservice/getNetworkAbuseTicketList?xsd=1 [wsimport] [ERROR] undefined element declaration 'ns2:Header' [wsimport] line 29 of http://localhost:8080/sams-tts-webservice/getNetworkAbuseTicketList?xsd=1 [wsimport] [ERROR] undefined element declaration 'ns2:Body' [wsimport] line 30 of http://localhost:8080/sams-tts-webservice/getNetworkAbuseTicketList?xsd=1 BUILD FAILED C:\workspace\SAMS-TTS-Java-WS\build.xml:142: Error starting wsimport: Total time: 1 second Can you tell me what is wrong with my wsdl? Thanks. -Andy Basu

    Posted by: santool123 on December 30, 2007 at 05:49 PM

  • Here is the wsdl: - - - - - - - - - - - - - - - - - and here is the xsd1: - - - - - - - - - - - -

    Posted by: santool123 on December 30, 2007 at 05:53 PM

  • What version of jax-ws does this require? I'm using 2.0, and the -b flag doesn't seem to have any effect.

    Posted by: jbarnum on March 16, 2008 at 12:11 AM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds