2015-01-16 3 views
0
내가 XSD에 내 웹 서비스 개체를 확인해야하고 내가하여 일을 해요

:자바 XML 검증 비누 ENC 네임 스페이스 예외

SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); 
factory.setResourceResolver(new ResourceResolver()); 
Source schemaFile = new StreamSource('Input stream with my xsd'); 
factory.newSchema(schemaFile); 

마지막 줄 - factory.newSchema (schemaFile); soap-enc 네임 스페이스를 사용하는 xsd 파일을 사용할 때 예외 및 예외가 발생합니다. 아래는 xsd 파일의 일부, 네임 스페이스 선언 및 네임 스페이스를 사용하는 복합 유형입니다.

<xsd:schema 
     xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
     xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"> 
     <xsd:complexType name="name"> 
       <xsd:sequence> 
        <xsd:element name="id" type="xsd:string"/> 
        <xsd:element name="names" type="soap-enc:Array"/> 
       </xsd:sequence> 
      </xsd:complexType> 

는 예외입니다 :이 스키마 파일에 정의되지 않은 배열 : org.xml.sax.SAXParseException; lineNumber: 20; columnNumber: 62; src-resolve.4.2: Error resolving component 'soap-enc:Array'. It was detected that 'soap-enc:Array' is in namespace 'http://schemas.xmlsoap.org/soap/encoding/', but components from this namespace are not referenceable from schema document 'null'. If this is the incorrect namespace, perhaps the prefix of 'soap-enc:Array' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'null'.

답변

1

이 XML 스키마는 비누 ENC를 입력 말합니다. 따라서 파일을 정의해야합니다.

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
      xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"> 
    <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" 
       schemaLocation="..."/> 
    <!-- ... 

네임 스페이스를 정의하는 위치에서 적절한 XML 스키마를 찾을 수 있습니다. 파일을 다운로드하여 로컬 파일 시스템에서 사용하는 것이 가장 좋다고 생각합니다. 자주 필요하면 더 효율적입니다. URL을 schemaLocation으로 사용하는 것도 효과가 있습니다.