WebService client exception (undefinedelement Declaration's: schema ')

Source: Internet
Author: User

Address: Code life (http://wensiqun.iteye.com/blog/1083340)

We are using the wsdl2java. when Bat generates a client call based on the WSDL file, the following error occurs: WSDL to Java error: thrown by jaxb: Undefined element Declaration's: schema 'at line 49 column 19 of schemafile:/D: /workspace/WebService/weather/WSDL/weather. WSDL

Because it is also temporary contact with cxf, so I don't know what the problem is. I searched the internet for a long time and said what to replace, but I didn't say why, in addition, it is basically to repost an article from someone outside China. I only know that I have lost the significance of doing technical work, because it is impossible to improve myself for a long time. So I am determined to understand why?

According to the error message, it seems that S: schema is not found. Check the WSDL file generated by. net. The file header contains the definition of S: schema namespace:

Xmlns: S = http://www.w3.org/2001/XMLSchema

However, it is also found that the WSDL file generated by cxf uses similar elements, but the namespace name defined is slightly different: xmlns: xs = http://www.w3.org/2001/XMLSchema

Therefore, it can be ruled out that the reason for the failure to find the S: schema element is certainly not the definition of XML itself.

Then I checked whether the introduction of WSDL had a version problem. After comparing the WSDL files of Java and. net, I felt that the version was consistent. Therefore, the reason for the WSDL version can also be ruled out.

Http://schemas.xmlsoap.org/wsdl/ (Java)

Http://schemas.xmlsoap.org/wsdl/soap/ (. NET)

After thinking, I decided to start with the idea of "What does ref mean in an xml configuration file. After reading a foreigner's article, I roughly understood its work. Ref is equivalent to a reference. The following is an example:

<element name="foo"> <complexType> <element ref="a:bar"/> </complexType> </element> <element name="bar"type="string"/> 

Equivalent to this:

<element name="foo"> <complexType> <element name="bar"type="string"/> </complexType> </element> 

After understanding the role of Ref, I naturally thought that wsdl2java uses jaxb to parse the WSDL file. Does it mean that jaxb currently does not support parsing elements such as ref, I found an article on the Internet or "XSD: Element ref not working with jaxb" on the Oracle official website, which seems to provide evidence for my thoughts, in some foreign articles, there are the following solutions for such errors: replace <s: Any minoccurs = "2" maxoccurs = "2"/> <s: element ref = "s: schema"/> <s: Any/>. I tried it, therefore, I can personally think that the wsdl2java generation error should be related to the XML ref not supported by jaxb. Because

<S: Any minoccurs = "2" maxoccurs = "2"/> and <s: Element ref = "s: schema"/> <s: any/> is actually equivalent. <S: Element ref = "s: schema"/> In fact, it can be replaced by any element type specified by S: schema. <s: any/> is playing this role.

<S: Any minoccurs = "2" maxoccurs = "2"/> is just to write two <s: Any/> statements.

·

Comment

5 floor, jiab121

For: http://www.webxml.com.cn/zh_cn/web_services.aspxwebsite, the WebService is A. Net-generated WSDL called in Java (such as the weather forecast service)

Solution:

Http://www.webxml.com.cn/WebServices/WeatherWebService? Save WSDL as weatherwebservice. WSDL is in the same directory as wsdl2java; open weatherwebservice. WSDL: delete all <s: elementref = "s: schema"/>, and then \ bin> wsdl2javaweatherwebservice. WSDL.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.