Subject: | ref'd elements are incorrectly qualified |
Date: | Tue, 13 Oct 2015 13:45:17 -0700 |
To: | bug-XML-Compile-SOAP [...] rt.cpan.org |
From: | Derek Hausauer <hausauer [...] gmail.com> |
I’m using XML-Compile-SOAP-3.12. It looks like ref elements are being fully qualified when they shouldn’t be.
Given the following WSDL:
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://somenamespace" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="SomeService" targetNamespace="http://somenamespace">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:tns="http://somenamespace" elementFormDefault="unqualified" targetNamespace="http://somenamespace" version="1.0">
<xs:import namespace="http://www.w3.org/2005/05/xmlmime"/>
<xs:element name="SomeParam" type="tns:SomeParam"/>
<xs:element name="SomeRefType" type="tns:SomeRefType"/>
<xs:element name="someMethod" type="tns:someMethod"/>
<xs:element name="someResponse" type="tns:someResponse"/>
<xs:complexType name="SomeParam">
<xs:sequence>
<xs:element minOccurs="0" ref="tns:SomeRefType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="SomeRefType">
<xs:sequence>
<xs:element name="SomeValue" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="genericResponse">
<xs:sequence>
<xs:element name="returnValue" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="someMethod">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="tns:SomeParam"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="someMethodResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="tns:genericResponse"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="someMethodResponse">
<wsdl:part element="tns:someMethodResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="someMethod">
<wsdl:part element="tns:someMethod" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:portType name="SomeService">
<wsdl:operation name="someMethod">
<wsdl:input message="tns:someMethod" name="someMethod"></wsdl:input>
<wsdl:output message="tns:someMethodResponse" name="someMethodResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SomeServiceSoapBinding" type="tns:SomeService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="someMethod">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="someMethod">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="someMethodResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SomeService">
<wsdl:port binding="tns:SomeServiceSoapBinding" name="SomeServicePort">
<soap:address location="http://localhost/SomeService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
In calling someMethod, the following request is generated:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<tns:someMethod xmlns:tns="http://somenamespace">
<arg0>
<tns:SomeParam>
<SomeValue>1</SomeValue>
</tns:SomeParam>
</arg0>
</tns:someMethod>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
<tns:SomeParam> should not have been qualified; it should appear as just <SomeParam>. I suspect this is because the reference is followed to a top-level element for which nsContext() in XML::Compile::Translate forces to a qualified tag. I’m not sure how to modify the code to prevent this from happening.
Because the request has "<tns:SomeParam>" instead of just "<SomeParam>", our SOAP web server (Apache CXF) throws the following exception:
Unmarshalling Error: unexpected element (uri:"http://somenamespace", local:"SomeParam"). Expected elements are <{}SomeParam>
Other frameworks (ie. JAX-WS) do not include the tns prefix on SomeParam and work fine.
—
Derek