错误:针对JDev 11g中的XSD验证XML [英] Error: Validating XML against XSD in JDev 11g
问题描述
我正在使用JDEV11.1.1.7.0.我是Webservices和SOAP的新手.我正在从现有的WSDL构建Web服务.
I am using JDEV11.1.1.7.0. I am a newbie to Webservices and SOAP. I am building a Web Service from an Existing WSDL.
即我先创建一个XSD和WSDL,然后在其上创建一个Web服务.我能够测试Web服务.我正在按要求获取输出.但是,当我针对XSD验证XML时,出现错误.
i.e. I create an XSD and WSDL and then creating a Web Service over it. I am able to test the web service. I am getting the output as required. But, when i validate the XML against the XSD, it has an error.
通过引用一个非常受欢迎的博客来准备XSD http://one-size-doesnt-fit-all.blogspot.in/2008/11/creating-jax-ws-web-services-via-wsdl.html
The XSD is prepared by referring to a very popular blog http://one-size-doesnt-fit-all.blogspot.in/2008/11/creating-jax-ws-web-services-via-wsdl.html
请求从HTTP分析工具中获取XML:
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
xmlns:ns1="http://www.sagecomputing.com.au">
<env:Header/>
<env:Body>
<ns1:formInput>
<ns1:inputField1>1</ns1:inputField1>
<ns1:inputField2>Morning</ns1:inputField2>
</ns1:formInput>
</env:Body>
</env:Envelope>
从HTTP分析工具获取的响应XML:
<?xml version = '1.0' encoding = 'UTF-8'?>
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">
<S:Body>
<formOutput xmlns="http://www.sagecomputing.com.au">
<outputField1>6</outputField1>
<outputField2>Morning: Welcome!</outputField2>
<outputField3>This is your reply</outputField3>
</formOutput>
</S:Body>
</S:Envelope>
XSD:
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.sagecomputing.com.au"
elementFormDefault="qualified">
<xsd:element name="formInput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="inputField1" type="xsd:integer"/>
<xsd:element name="inputField2" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="formOutput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="outputField1" type="xsd:integer"/>
<xsd:element name="outputField2" type="xsd:string"/>
<xsd:element name="outputField3" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
针对XSD验证XML时,出现以下错误.
When the XML is validated against the XSD, I get the below error.
Cvc-elt.1: Cannot Find The Declaration Of Element 'S:Envelope'.. Line '1', Column '63'
我对XSD架构使用免费的在线XML验证器进行了比较- http://www. freeformatter.com/xml-validator-xsd.html
I compared using Free Online XML Validator Against XSD Schema - http://www.freeformatter.com/xml-validator-xsd.html
有人可以告诉我,我在做什么错?
Can someone please tell me, what is the mistake I am doing?
我缺少任何进口吗?
推荐答案
尝试使用以下xsd:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.sagecomputing.com.au"
elementFormDefault="qualified">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/envelope/"
schemaLocation="http://schemas.xmlsoap.org/soap/envelope/"/>
<xsd:element name="formInput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="inputField1" type="xsd:integer"/>
<xsd:element name="inputField2" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="formOutput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="outputField1" type="xsd:integer"/>
<xsd:element name="outputField2" type="xsd:string"/>
<xsd:element name="outputField3" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
更新:
针对上述xsd验证您的SOAP请求消息:
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://www.sagecomputing.com.au"
xsi:schemaLocation="http://www.sagecomputing.com.au soapMessage.xsd">
<Header/>
<Body>
<ns1:formInput>
<ns1:inputField1>1</ns1:inputField1>
<ns1:inputField2>Morning</ns1:inputField2>
</ns1:formInput>
</Body>
</Envelope>
针对上述xsd验证您的SOAP响应消息:
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sagecomputing.com.au soapMessage.xsd">
<Header/>
<Body>
<formOutput xmlns="http://www.sagecomputing.com.au">
<outputField1>6</outputField1>
<outputField2>Morning: Welcome!</outputField2>
<outputField3>This is your reply</outputField3>
</formOutput>
</Body>
</Envelope>
这篇关于错误:针对JDev 11g中的XSD验证XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!