How to fix soapenv:Envelope issue in XSD schema while validating with SOAP request/response

前端 未结 3 1647
隐瞒了意图╮
隐瞒了意图╮ 2020-12-10 15:12

I have a SOAP request :-



        
相关标签:
3条回答
  • 2020-12-10 16:13

    I had the same problem and for me schema import didn't work. Stack:

        10:18:03,206 | DEBUG | iEsb | DefaultValidationErrorHandler    |  | 68 - org.apache.camel.camel-core - 2.6.0.fuse-03-01 | Validation error: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'soapenv:Envelope'.
    org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'soapenv:Envelope'.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:233)[:]
    

    My java version was: 1.6.0_45. But I solved it through downloading xsd and importing it as a file:

    <xsd:import namespace="http://schemas.xmlsoap.org/soap/envelope/" schemaLocation="envelope.xsd" />
    

    Maybe it will help somebody.

    0 讨论(0)
  • 2020-12-10 16:15

    So, the final solution that worked for me is using import :-

    <import namespace="http://schemas.xmlsoap.org/soap/envelope/"   
                schemaLocation="http://schemas.xmlsoap.org/soap/envelope/"></import>
    
    0 讨论(0)
  • 2020-12-10 16:18

    The SOAP request and response don't validate against your schema, but the SOAP schema. You can use your XSD to validate your request and response if you import the SOAP XSD into it:

    <schema xmlns="http://www.w3.org/2001/XMLSchema" 
        targetNamespace="http://services.test.com/schema/MainData/V1" 
        xmlns:tns="http://services.test.com/schema/MainData/V1" elementFormDefault="qualified">
    
        <import namespace="http://schemas.xmlsoap.org/soap/envelope/"   
                schemaLocation="http://schemas.xmlsoap.org/soap/envelope/"></import>
    
    ...
    

    You don't have to do that if your instance declares a schemaLocation attribute mapping the namespaces of both schemas (yours and the SOAP schema) to their locations:

    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://services.test.com/schema/MainData/V1 your-schema.xsd
                            http://schemas.xmlsoap.org/soap/envelope/ http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Body>
            <retrieveDataResponse xmlns="http://services.test.com/schema/MainData/V1">
                <Response>The Data retrieved from the Database</Response>
                <Id>58</Id>
                <Name>fdfdf</Name>
                <Age>44</Age>
                <Designation>sse</Designation>
            </retrieveDataResponse>
        </soap:Body>
    </soap:Envelope>
    
    0 讨论(0)
提交回复
热议问题