How to make connection to the WSDL in SpringBoot application? - web-services

I am new to WSDL. I have a WSDL and need to make a connection to the endpoint using springBoot application and verify its working.
In my java class SoapClientConfig, I need contextPath and default Uri to set. With given WSDL, I am not sure what would be my contextPath and default Uri.
In the WSDL, I see following tag for address location.I am not sure, how to use this address in my Springboot application to make a connection to the API provided by same WSDL
<wsdl:service name="PayServices">
<wsdl:port name="BasicHttpBinding_PayServices"
binding="tns:BasicHttpBinding_PayServices">
<soap:address
location="https://test.testfw.ws/ts/gpcs/grsv/routerservice.svc"/>
</wsdl:port>
</wsdl:service>
One of the API operation outcome
<wsdl:operation name="PaymentOutcome">
<soap:operation
soapAction="http://hide.net/services/atms/PayServices/PaymentOutcome" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
<soap:header message="tns:PayServices_RouterAddressing" part="ADDRESSING" use="literal"/>
<soap:header message="tns:PayServices_RouterSecurity" part="SECURITY" use="literal"/>
<soap:header message="tns:PayServices_Security" part="Security" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="SecurityFault">
<soap:fault name="SecurityFault" use="literal"/>
</wsdl:fault>
<wsdl:fault name="RouterFault">
<soap:fault name="RouterFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
Java code for SOap client connection:
#Configuration
public class SoapClientConfig {
#Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
// this package must match the package in the <generatePackage> specified in
// pom.xml
marshaller.setContextPath("");
return marshaller;
}
#Bean
public PaymentOutcomeClient paymentOutcomeClient(Jaxb2Marshaller marshaller) {
PaymentOutcomeClient client = new PaymentOutcomeClient();
client.setDefaultUri("http://localhost:8080");
client.setMarshaller(marshaller);
client.setUnmarshaller(marshaller);
return client;
}
}

Related

Receive duplicate wsdl:binding and wsdl:service when accessing ?wsdl page

I created a WSDL and exposed a web service as CXF endpoint at JBoss Fuse. I specified one wsdl:binding and one wsdl:service in the WSDL, but after deployed it to JBoss Fuse and accessed http://localhost:8081/PlaceOrderService?wsdl, I got duplicate wsdl:binding and wsdl:service. Anyone know why?
WSDL - one wsdl:binding and wsdl:service
<wsdl:message name="orderRecordRequest">
<wsdl:part name="orderRecordInput" element="typens:orderRecordRequest" />
</wsdl:message>
<wsdl:message name="orderRecordResponse">
<wsdl:part name="orderRecordOutput" element="typens:orderRecordResponse"/>
</wsdl:message>
<wsdl:portType name="PlaceOrderService">
<wsdl:operation name="OrderService">
<wsdl:input message="tns:orderRecordRequest"/>
<wsdl:output message="tns:orderRecordResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="PlaceOrderServiceSOAPBinding" type="tns:PlaceOrderService">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="OrderService">
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="PlaceOrderService">
<wsdl:port binding="tns:PlaceOrderServiceSOAPBinding" name="PlaceOrderPort">
<soap:address location="http://localhost:8081/PlaceOrderService"/>
</wsdl:port>
</wsdl:service>
http://localhost:8081/PlaceOrderService?wsdl
duplicate wsdl:binding and wsdl:service
<wsdl:binding name="PlaceOrderServiceSOAPBinding" type="tns:PlaceOrderService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="OrderService">
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="PlaceOrderServiceSoapBinding" type="tns:PlaceOrderService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="OrderService">
<soap:operation soapAction="" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="PlaceOrderServiceService">
<wsdl:port binding="tns:PlaceOrderServiceSoapBinding" name="PlaceOrderServicePort">
<soap:address location="http://localhost:8081/PlaceOrderService"/>
</wsdl:port>
</wsdl:service>
<wsdl:service name="PlaceOrderService">
<wsdl:port binding="tns:PlaceOrderServiceSOAPBinding" name="PlaceOrderPort">
<soap:address location="http://localhost:8081/PlaceOrderService"/>
</wsdl:port>
</wsdl:service>
I know I'm late for that train, but for those with similar issues: note the different case in bindings name, make sure names in WSDL match names in generated Java classes.

CXF autogenerates WSDL imports itself?

I develop a code first SOAP web service with CXF, and this a WSDL which I get. Why is there a import on WSDL
the second line is the one of the interest:
I am guessing that maybe it has something to do with namespaces ? I wonder if publishing the code of the web service impl will help ?
<wsdl:import location="http://localhost:8080/abc/RaceCalc?wsdl=RaceCalc.wsdl" namespace="http://service.wrapper.ie/">
</wsdl:import>
WSDL generated from Web Service:
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions name="RaceCalcImplService" targetNamespace="http://impl.service.wrapper.ie/" xmlns:ns1="http://service.wrapper.ie/" xmlns:ns2="http://cxf.apache.org/bindings/xformat" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://impl.service.wrapper.ie/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:import location="http://localhost:8080/abc/RaceCalc?wsdl=RaceCalc.wsdl" namespace="http://service.wrapper.ie/">
</wsdl:import>
<wsdl:binding name="RaceCalcImplServiceSoapBinding" type="ns1:RaceCalc">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="setRaceCalcHelper">
<soap:operation soapAction="" style="document" />
<wsdl:input name="setRaceCalcHelper">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="setRaceCalcHelperResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="calculate">
<soap:operation soapAction="" style="document" />
<wsdl:input name="calculate">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="calculateResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="RaceCalcImplService">
<wsdl:port binding="tns:RaceCalcImplServiceSoapBinding" name="RaceCalcImplPort">
<soap:address location="http://localhost:8080/abc/RaceCalc" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Because you have two different namespaces on your implementation: {http://service.wrapper.ie/} and {http://impl.service.wrapper.ie/}. You surely have the interface in package ie.wrapper.service and the implementation in ie.wrapper.service.impl. CXF is therefore assuming the namespace {http://service.wrapper.ie/} for the logical stuff (interface/portType) and the namespace {http://impl.service.wrapper.ie/} for the physical stuff (impl/service/binding). Adding the #WebService(targetNamespace = "http://whatever.you.want") annotation to both, interface and implementation should remove the (need of an) import in the WSDL.

gSOAP wrong proxy C++ class generated for multiple operations

I have the following part of wsdl file:
<wsdl:binding name="Binding" type="intf:PortType">
<wsdlsoap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<wsdl:operation name="Op1">
<wsdlsoap:operation soapAction=""/>
<wsdl:input>
<wsdlsoap:body use="encoded" namespace="Op1" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:input>
<wsdl:output>
<wsdlsoap:body use="encoded" namespace="services:ca" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Op2">
<wsdlsoap:operation soapAction=""/>
<wsdl:input>
<wsdlsoap:body use="encoded" namespace="Op2" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:input>
<wsdl:output>
<wsdlsoap:body use="encoded" namespace="services:ca" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Op3">
<wsdlsoap:operation soapAction=""/>
<wsdl:input>
<wsdlsoap:body use="encoded" namespace="Op3" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:input>
<wsdl:output>
<wsdlsoap:body use="encoded" namespace="services:ca" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
The problem is that soapcpp2 generates soapBidingProxy.h files iteratively, effectively overwriting old file (for Op1 and Op2), and leaving me with proxy class for Op3 only. Is this soapcpp2 bug, or I am doing something wrong.
I figured it out. The problem was that in the input body namespace. If the namespace is the same for all operations, the generated file is only one, and includes all the methods. Thanks All.

How to find the binding interface cxf is creating

In my previous question I was told that CXF implements the javax.xml.ws.BindingProvider interface.
I've the following WSDL file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- May 30, 2006 -->
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:interface="http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/interface" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/service" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="parlayx_sms_send_service" targetNamespace="http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/service">
<wsdl:import location="parlayx_sms_send_interface_2_2.wsdl" namespace="http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/interface"/>
<wsdl:binding name="SendSmsBinding" type="interface:SendSms">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sendSms">
<soap:operation soapAction="" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="ServiceException">
<soap:fault name="ServiceException" use="literal"/>
</wsdl:fault>
<wsdl:fault name="PolicyException">
<soap:fault name="PolicyException" use="literal"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="getSmsDeliveryStatus">
<soap:operation soapAction="" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="ServiceException">
<soap:fault name="ServiceException" use="literal"/>
</wsdl:fault>
<wsdl:fault name="PolicyException">
<soap:fault name="PolicyException" use="literal"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="sendSmswithUDH">
<soap:operation soapAction="" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="ServiceException">
<soap:fault name="ServiceException" use="literal"/>
</wsdl:fault>
<wsdl:fault name="PolicyException">
<soap:fault name="PolicyException" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SendSmsService">
<wsdl:port binding="tns:SendSmsBinding" name="SendSms">
<soap:address location="http://202.126.44.5:9080/SendSmsServices/services/SendSms"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
And the CXF creates sendSmsService and interface called sendSms but none of them is related to BindingProvider interface, and I have to find a way to set to this service user name, password and endpoint.
How can I find the binding interface or is there another way I can do it? Thanks.

Importing wsdl in Delphi don't add soap header

I have problem when I import wsdl in Delphi. My soap header is not added in my binding.
What is the problem ?
<wsdl:operation name="singleSms">
<soap:operation soapAction=""/>
<wsdl:input>
<soap:header use="literal" part="request_header" message="tns:identityHeader"></soap:header>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
http://www.smsconnect.ma:8000/wsdl/MCMS.wsdl