Forum Discussion

archenroot's avatar
archenroot
Occasional Contributor
12 years ago

API Class WsdlValidator - result OK on SOAP without Body

Hi,

first of all, thank you for your very good and hard work! I personally will definitely purchase the the pro version as Christmas gift :-)

I am using SoapUI for many years as it was delivered in SOAP service world. As soon as I work now on automation testing framework in Java for Oracle Service Bus which will be invoked by SoapUI TestSteps of type Groovy script, I went down into the API, well it is huge, hehe.

The API itself is well developed, I like the clean style of code, but the documentation is little bit worse. Not all methods are understandable from the first sights, but... it is minor thing.

Now to my problem: I generate the default request for the Soap proxy service:

soap test component constructor {
this.wsdlInterface = WsdlInterfaceFactory.importWsdl(this.wsdlProject,
this.soapEndPointUri + SoapTestComponent.wsdlUriSuffix,
true)[0];
this.wsdlContext = new WsdlContext(this.soapEndPointUri, this.wsdlInterface);
// get desired operation
this.wsdlValidator = new WsdlValidator(wsdlContext);
this.wsdlOperation = (WsdlOperation) wsdlInterface.getOperationByName(this.soapOperationName);
// create a new empty request for that operation
this.wsdlRequest = wsdlOperation.addNewRequest(SoapTestComponent.newRequestDefaultName);
// generate the request content from the schema
this.wsdlRequest.setRequestContent(wsdlOperation.createRequest(true));
this.soapRequestXmlDocument = new RequestXmlDocument(this.wsdlRequest);
}

This is ok. I get the document by using getXml() method an save it to the file, it looks in my demo like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sen="http://www.example.org/SendJMS">
<soapenv:Header/>
<soapenv:Body>
<sen:sendJMSMessage>
<sen:messageContent>?</sen:messageContent>
</sen:sendJMSMessage>
</soapenv:Body>
</soapenv:Envelope>


Now if I call:
List<XmlError> errors = null;
this.wsdlValidator.validateXml(soapContent, error);
now in this case I expect the error variable of type XmlError (org.apache.xmlbeans.XmlError) will stay null as soon as the soap is valid.

In case I change the content to this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sen="http://www.example.org/SendJMS">
<soapenv:Header/>

</soapenv:Envelope>

the error variable is still null, but the Body is required by the soap specification:
<xs:complexType name="Envelope">
<xs:sequence>
<xs:element ref="tns:Header" minOccurs="0"/>
<xs:element ref="tns:Body" minOccurs="1"/>
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
</xs:sequence>

The validator is from my perspective not working as expected, I didn't debug the source code yet. Regarding this I also would like to ask, if the namespace url really keeps the XSD file for the body message paylod, should then the validator validate not only envelope but all other namespaces linked?
xmlns:sen="http://www.example.org/SendJMS" for example if here will be really available XSD, will the validator validate follwing part of SOAP envelope message also?:
<sen:sendJMSMessage>
<sen:messageContent>?</sen:messageContent>
</sen:sendJMSMessage>

Thank you very much for your ideas, maybe I am doing something wrong.

Ladislav

1 Reply

  • archenroot's avatar
    archenroot
    Occasional Contributor
    Any hints here? I think the validator is not working as expected, I will do more test today and post the result. Looks to me like bug for now.