I have a 3rd party SOAP service. When I call the end point of the service using POSTMAN it sends the data back
POST - https://localhost:8443/api/PatronSearch
POSTMAN Body
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sch="http://www.myservice.com/api/schema">
<soapenv:Header/>
<soapenv:Body>
<sch:PatronSearch>
<sch:Patron>
<sch:LastName>Summers</sch:LastName>
</sch:Patron>
</sch:PatronSearch>
</soapenv:Body>
</soapenv:Envelope>
Response in POSTMAN
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<PatronList xmlns:ns2="http://www.myservice.com/api" xmlns="http://www.myservice.com/api/schema">
<Patron xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="EmployeeData">
<Id>1</Id>
<Type>Employee</Type>
<ReadOnly>false</ReadOnly>
<LastName>Summers</LastName>
<FirstName>Petron</FirstName>
<Gender>Male</Gender>
<PhoneNo>+14567891234</PhoneNo>
<Language>en</Language>
<MobilePhoneNo>+14567891235</MobilePhoneNo>
<Email>[email protected]</Email>
<DepartmentId>2</DepartmentId>
</Patron>
</PatronList>
</soap:Body>
</soap:Envelope>
but when I try to access same service using java then it is throwing me following error
org.springframework.ws.soap.client.SoapFaultClientException: Unexpected element findPatron found. Expected {http://www.myservice.com/api/schema}PatronSearch.
Here is the method from where I am calling this service
public PatronList getPatronInfo(PatronSearch patronSearch) {
template = new WebServiceTemplate(marshaller);
JAXBElement<PatronSearch> jaxbElement = new JAXBElement<PatronSearch>(new QName("", "findPatron"),
PatronSearch.class, patronSearch);
PatronList patronList = (PatronList) template
.marshalSendAndReceive("https://localhost:8443/api/PatronSearch", jaxbElement);
return patronList;
}
here is the snap shot of wsdl
<?xml version="1.0" encoding="utf-8"?>
<!--Created with Liquid XML Studio Developer Edition 9.1.11.3570 (http://www.liquid-technologies.com)-->
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://example.com/" xmlns:ns="http://www.myservice.com/api/schema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" name="myservice" targetNamespace="http://www.myservice.com/api" xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<xs:schema xmlns:tns="http://schemas.xmlsoap.org/wsdl/">
<xs:import schemaLocation="MyServiceWebService.xsd" namespace="www.myservice.com/api/schema" />
</xs:schema>
</types>
<message name="PatronSearch">
<part xmlns:q1="http://www.myservice.com/api/schema" name="search" element="q1:PatronSearch" />
</message>
<message name="PatronList">
<part xmlns:q1="http://www.myservice.com/api/schema" name="list" element="q1:PatronList" />
</message>
<portType name="MyServiceWebServiceType">
<operation name="findPatron">
<input xmlns:q1="http://www.myservice.com/api" name="findPatron" message="q1:PatronSearch" />
<output xmlns:q1="http://www.myservice.com/api" name="listPatron" message="q1:PatronList" />
<fault xmlns:q1="http://www.myservice.com/api" name="fout" message="q1:Fault" />
</operation>
</portType>
<binding xmlns:q1="http://www.myservice.com/api/" name="MyServiceWebServiceSoapBinding" type="q1:MyServiceWebServiceType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="findPatron">
<input name="findPatron" />
<output name="listPatron" />
<fault name="fout" />
</operation>
</binding>
<service name="MyServiceWebService">
<port xmlns:q1="http://www.myservice.com/api" name="MyServiceWebServicePort" binding="q1:MyServiceWebServiceSoapBinding">
<soap:address location="https://localhost:8443/api" />
</port>
</service>
</definitions>
any suggestion what I am doing wrong or a better way to call the service.