找不到元素'soapenv:Envelope'的声明

时间:2016-01-27 12:01:56

标签: java xml soap

我收到错误无法找到元素声明soapenv:Envelope

我收到错误无法找到元素声明soapenv:Envelope

'<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/ http://schemas.xmlsoap.org/soap/envelope/ /tmp/checkxsd.xsd"><soapenv:Body>
  <ns:getEntitiesByFilterResponse xmlns:ns="http://services" xmlns:ax21="http://objects.services/xsd">
     <ns:return xsi:type="ax21:EntityObj">
        <ax21:entityId>1065798192</ax21:entityId>
        <ax21:entityTypeId>4</ax21:entityTypeId>
        <ax21:methodValues xsi:type="ax21:ValuePair">
           <ax21:elementValue>Project SoapUI 001</ax21:elementValue>
           <ax21:id>436</ax21:id>
        </ax21:methodValues>
        <ax21:methodValues xsi:type="ax21:ValuePair">
           <ax21:elementValue>Project SoapUI 001</ax21:elementValue>
           <ax21:id>100461</ax21:id>
        </ax21:methodValues>
        <ax21:methodValues xsi:type="ax21:ValuePair">
           <ax21:elementValue>Project SoapUI 001</ax21:elementValue>
           <ax21:id>400015</ax21:id>
        </ax21:methodValues>
     </ns:return>
     <ns:return xsi:type="ax21:EntityObj">
        <ax21:entityId>1065835163</ax21:entityId>
        <ax21:entityTypeId>4</ax21:entityTypeId>
        <ax21:methodValues xsi:type="ax21:ValuePair">
           <ax21:elementValue>Project SoapUI 002</ax21:elementValue>
           <ax21:id>436</ax21:id>
        </ax21:methodValues>
        <ax21:methodValues xsi:type="ax21:ValuePair">
           <ax21:elementValue>Project SoapUI 002</ax21:elementValue>
           <ax21:id>100461</ax21:id>
        </ax21:methodValues>
        <ax21:methodValues xsi:type="ax21:ValuePair">
           <ax21:elementValue>Project SoapUI 002</ax21:elementValue>
           <ax21:id>400015</ax21:id>
        </ax21:methodValues>
     </ns:return>
     <ns:return xsi:type="ax21:EntityObj">
        <ax21:entityId>1317237376</ax21:entityId>
        <ax21:entityTypeId>4</ax21:entityTypeId>
        <ax21:methodValues xsi:type="ax21:ValuePair">
           <ax21:elementValue>CopyTask_project_1448004605927</ax21:elementValue>
           <ax21:id>436</ax21:id>
        </ax21:methodValues>
        <ax21:methodValues xsi:type="ax21:ValuePair">
           <ax21:elementValue>CopyTask_project_1448004605927</ax21:elementValue>
           <ax21:id>100461</ax21:id>
        </ax21:methodValues>
        <ax21:methodValues xsi:type="ax21:ValuePair">
           <ax21:elementValue>CopyTask_project_1448004605927</ax21:elementValue>
           <ax21:id>400015</ax21:id>
        </ax21:methodValues>
     </ns:return>
  </ns:getEntitiesByFilterResponse></soapenv:Body></soapenv:Envelope>'

我的java代码如下 - 请帮助

我收到错误无法找到元素声明soapenv:Envelope

SchemaFactory factory =
                SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Schema schema = factory.newSchema(new File("/tmp/checkxsd.xsd"));
        Validator validator = schema.newValidator();
        validator.validate(new StreamSource(new File("/home/my-pc/MyXMLFile.xml")));

我的xsd是 -

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://objects.services/xsd">
   <xs:element name="entityId">
      <xs:simpleType>
         <xs:restriction base="xs:int">
            <xs:enumeration value="1065798192" />
            <xs:enumeration value="1065835163" />
            <xs:enumeration value="1317237376" />
         </xs:restriction>
      </xs:simpleType>
   </xs:element>
   <xs:element name="entityTypeId" type="xs:byte" />
   <xs:element name="methodValues">
      <xs:complexType>
         <xs:sequence>
            <xs:element name="elementValue">
               <xs:simpleType>
                  <xs:restriction base="xs:string">
                     <xs:enumeration value="Project SoapUI 001" />
                     <xs:enumeration value="Project SoapUI 002" />
                     <xs:enumeration value="CopyTask_project_1448004605927" />
                  </xs:restriction>
               </xs:simpleType>
            </xs:element>
            <xs:element name="id">
               <xs:simpleType>
                  <xs:restriction base="xs:int">
                     <xs:enumeration value="436" />
                     <xs:enumeration value="100461" />
                     <xs:enumeration value="400015" />
                  </xs:restriction>
               </xs:simpleType>
            </xs:element>
         </xs:sequence>
      </xs:complexType>
   </xs:element>
</xs:schema>

0 个答案:

没有答案