Forum Discussion

epkjoja's avatar
epkjoja
New Contributor
12 years ago

Request validation using key/keyref is not working

I have a WSDL that is using key/keyref constraints imported in a fresh SoapUI project. I then let SoapUI generate an example request for me and enter valid values into the XML. When I try to validate the request in SoapUI it complains with "line 6: Key 'A' not found for keyref constraint 'keyref_id@http://test.com'" even though the request is valid.

When I try to validate the exact same schema and XML in an online schema validator they say that the request is perfectly fine. I have checked with both http://www.utilities-online.info/xsdval ... validation and http://www.freeformatter.com/xml-validator-xsd.html

This is the example request that I am testing with:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://test.com">
<soapenv:Header/>
<soapenv:Body>
<test:CreateService id="A">
<test:id>A</test:id>
<test:whatEver>1234</test:whatEver>
</test:CreateService>
</soapenv:Body>
</soapenv:Envelope>


This is the WSDL/schema I am using:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://test.com" targetNamespace="http://test.com">
<wsdl:types>
<xs:schema xmlns:tns="http://test.com" targetNamespace="http://test.com" elementFormDefault="qualified">
<xs:element name="CreateService">
<xs:complexType>
<xs:sequence>
<xs:element name="id" type="xs:string"/>
<xs:element name="whatEver" type="xs:integer"/>
</xs:sequence>
<xs:attribute name="id" type="xs:string" use="required"/>
</xs:complexType>
<xs:key name="key_id">
<xs:selector xpath="."/>
<xs:field xpath="@id"/>
</xs:key>
<xs:keyref name="keyref_id" refer="tns:key_id">
<xs:selector xpath="."/>
<xs:field xpath="tns:id"/>
</xs:keyref>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="NewMessageRequest">
<wsdl:part name="parameter" element="tns:CreateService"/>
</wsdl:message>
<wsdl:message name="NewMessageResponse">
<wsdl:part name="parameter" type="xs:string"/>
</wsdl:message>
<wsdl:portType name="NewPortType">
<wsdl:operation name="NewOperation">
<wsdl:input message="tns:NewMessageRequest"/>
<wsdl:output message="tns:NewMessageResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="NewBinding" type="tns:NewPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="NewOperation">
<soap:operation soapAction="urn:#NewOperation"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="NewService">
<wsdl:port name="NewPort" binding="tns:NewBinding">
<soap:address location="No Target Adress"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>


I am using SoapUI 5.0.0 but the error also exists for older versions. OS is Win 7.