Soap request Message part was not recognized
I think the problem is that the target namespace in the wsdl and the one in the schema are the same:
<?xml version="1.0" encoding="ISO-8859-1"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://localhost:8181/cxf/webservices/inputoutput"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://localhost:8181/cxf/webservices/inputoutput">
<!-- Type definitions for input- and output parameters for webservice -->
<wsdl:types>
<xs:schema targetNamespace="http://localhost:8181/cxf/webservices/inputoutput">
...
And then in the message part when you use the 'tns' prefix in tns:input
it cannot resolve the element:
<wsdl:message name="input">
<wsdl:part name="surname" element="tns:input"/>
</wsdl:message>
You can try defining a different target namespace in the schema declaration and adding a new prefix in <wsdl:definitions>
to that namespace.
<?xml version="1.0" encoding="ISO-8859-1"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://localhost:8181/cxf/webservices/inputoutput"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://localhost:8181/cxf/webservices/inputoutput"
xmlns:types="http://localhost:8181/cxf/webservices/inputoutput/types">
<!-- Type definitions for input- and output parameters for webservice -->
<wsdl:types>
<xs:schema targetNamespace="http://localhost:8181/cxf/webservices/inputoutput/types">
...
And then in the message part use this new prefix:
<wsdl:message name="input">
<wsdl:part name="surname" element="types:input"/>
</wsdl:message>
Right now I don't remember if it's mandatory to define different targetnamespaces for the wsdl and the schema in the types element, but I do remember facing a similar issue, and it's also considered a best practice to do so.
I usually create at least two schemas, one for the 'in' and another for the 'out' parameters both having their own namespace to avoid possible name collisions.
Milla
Updated on June 12, 2022Comments
-
Milla almost 2 years
When I send a request to my webservice (build with apache camel and running on apache karaf) I always get
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <soap:Fault> <faultcode>soap:Client</faultcode> <faultstring>Message part {http://localhost:8181/cxf/webservices/inputoutput}input was not recognized. (Does it exist in service WSDL?)</faultstring> </soap:Fault> </soap:Body> </soap:Envelope>
My wsdl looks like this
<?xml version="1.0" encoding="ISO-8859-1"?> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://localhost:8181/cxf/webservices/inputoutput" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://localhost:8181/cxf/webservices/inputoutput"> <!-- Type definitions for input- and output parameters for webservice --> <wsdl:types> <xs:schema targetNamespace="http://localhost:8181/cxf/webservices/inputoutput"> <xs:element name="input"> <xs:complexType> <xs:sequence> <xs:element type="xs:string" name="surname"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="output"> <xs:complexType> <xs:sequence> <xs:element type="xs:string" name="forename"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> </wsdl:types> <!-- Message definitions for input and output --> <wsdl:message name="input"> <wsdl:part name="surname" element="tns:input"/> </wsdl:message> <wsdl:message name="output"> <wsdl:part name="forename" element="tns:output"/> </wsdl:message> <!-- Port (interface) definitions --> <wsdl:portType name="InputOutputEndpoint"> <wsdl:operation name="InputOutput"> <wsdl:input message="tns:input"/> <wsdl:output message="tns:output"/> </wsdl:operation> </wsdl:portType> <!-- Port bindings to transports and encoding - HTTP, document literal encoding is used --> <wsdl:binding name="InputOutputBinding" type="tns:InputOutputEndpoint"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="InputOutput"> <soap:operation soapAction="http://localhost:8181/cxf/webservices/inputoutput" style="document"/> <wsdl:input> <soap:body parts="in" use="literal"/> </wsdl:input> <wsdl:output> <soap:body parts="out" use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <!-- Service definition --> <wsdl:service name="InputOutputEndpointService"> <wsdl:port name="InputOutputEndpoint" binding="tns:InputOutputBinding"> <soap:address location="http://localhost:8181/cxf/webservices/inputoutput"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
And this is my request in SoapUI
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rep="http://localhost:8181/cxf/webservices/inputoutput"> <soapenv:Header/> <soapenv:Body> <rep:input> <surname>test</surname> </rep:input> </soapenv:Body> </soapenv:Envelope>
I can't find anything wrong in my wsdl here. Anyone got an idea what leads to this?
-
Milla over 8 yearsUnfortunately this didnt change anything except changing the response to "[...]Message part {localhost:8181/cxf/webservices/inputoutput/types}input was not recognized.[...]"
-
David Lizárraga over 8 yearsI created a ws using your initial wsdl and tested it with SoapUI using your soap request and it works correctly. This fault is generated in
org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage
, when after extracting the part out of the request message the part is null. In my test I could see that the part was extracted correctly. How did you generate the classes from the wsdl? What I did was just to generate the classes with the maven plugin cxf-codegen-plugin, and create a class that implements the generated service endpoint interface (@Webservice
). -
Milla over 8 yearsI also generated the classes with cxf-codegen-plugin. I built up a complete new project and now I get "[..] Could not find portType named {myPackage}InputOutputEndpointServicePortType[..]" in my karaf logs. I build my blueprint.xml just like the one out of the example generated with the camel maven cxf blueprint archetype (getting the same error when trying to run this example...)
-
Eduard Nickel over 3 years
<xsd:element name="items" type="itms:item"/><xsd:complexType name="item">...
it doesn't help :(