XML模式验证中的错误

时间:2016-12-29 07:29:57

标签: soap wsdl schema soapui xsd-validation

我有一个特定的Java类,如

public class JavaClass implements Serializable{


    private static final long serialVersionUID = 1L;
    private ElementC ElementC = null;
    private ArrayList<ElementA> elementA = new ArrayList<ElementA>();
    private ArrayList<ElementB> elementB = new ArrayList<ElementB>();

和特定类的WSDL一起生成的XSD,如下所示。

(XSD档案)

<xs:complexType name="JavaClass">
    <xs:sequence>
      <xs:element name="ElementA" type="tns:elementA" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="ElementB" type="tns:elementB" nillable="true" minOccurs="1" maxOccurs="unbounded"/>
      <xs:element name="ElementC" type="xs:string" minOccurs="1"/>
    </xs:sequence>
  </xs:complexType>

以下是用于模式验证的Java代码块。

当我调试以查看抛出的解析异常时,消息显示

其中一个{elementA,elementB}&#39;预计。 (我认为问题出在SAXParseException。

public void warning(SAXParseException e) throws SAXException {
        //System.out.println("In Warning() of SchemaErrorHandler");
        // Store warnings in the packet so that they can be retrieved from the endpoint        
        packet.invocationProperties.put("WARNING", e);    
    }
    public void error(SAXParseException e) throws SAXException 
    {
        count++;

        String error = e.getMessage();

        if(error.contains("cvc-enumeration-valid")){
            StringTokenizer st = new StringTokenizer(error,"[");
            st.nextElement();
            StringTokenizer st2 = new StringTokenizer(st.nextElement().toString(),"]");
            exceptionTypeDetails = (String) st2.nextElement();

现在,当我在没有 ElementB 强制)的情况下触发SOAP请求时,SOAP会抛出一条错误,说“&strong; ElementA 未找到,ExAspted ElementA&#34;(即使ElementA不是强制性的)。

请停止如何调试问题。让我知道在这个问题上需要进一步澄清。

0 个答案:

没有答案