<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Volkan Güngör on Medium]]></title>
        <description><![CDATA[Stories by Volkan Güngör on Medium]]></description>
        <link>https://medium.com/@volkan.gungor?source=rss-70f2b01bae8d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Volkan Güngör on Medium</title>
            <link>https://medium.com/@volkan.gungor?source=rss-70f2b01bae8d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 13:17:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@volkan.gungor/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Consuming SOAP Service With Apache CXF and Spring]]></title>
            <link>https://medium.com/turkcell/consuming-soap-service-with-apache-cxf-and-spring-5dce25a553?source=rss-70f2b01bae8d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5dce25a553</guid>
            <dc:creator><![CDATA[Volkan Güngör]]></dc:creator>
            <pubDate>Tue, 04 Jan 2022 14:35:49 GMT</pubDate>
            <atom:updated>2022-01-04T14:35:49.205Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*vknLaoUYViN4FtCbHHCMCQ.png" /></figure><p>SOAP web services are not popular anymore but if you are working with old applications, you probably still have to deal with SOAP web services. I am going to give you an example of how to consume a SOAP service with CXF, how to make a configuration for it, and how to log requests and responses to it.</p><h3>A Simple Web Service</h3><p>Before I can consume a web service, I need a simple web service to work with. For the project, I am going to use Spring Boot version 2.5.0 and Java 11. You can use another version if you like; it does not matter as long as the versions are not too old. You can easily create a Spring Boot project with a <em>Spring Initializer</em>. If you use maven, pom.xml should be like this. If you use Java 8, you do not need to have a “JAXB Runtime” dependency.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/996d39ad0747c4f8fd5c21faa44ce13f/href">https://medium.com/media/996d39ad0747c4f8fd5c21faa44ce13f/href</a></iframe><p>First of all, I will create an interface for my simple web service like below. As you see, it will get a single string parameter and returns a string response.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05e6fa850cdf7db2486ef29c0baccdf1/href">https://medium.com/media/05e6fa850cdf7db2486ef29c0baccdf1/href</a></iframe><p>And, now, I need an implementation of this interface. It will just add “Hello” in front of the input parameter and return it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/890659498fda3750a02acb10944f7e04/href">https://medium.com/media/890659498fda3750a02acb10944f7e04/href</a></iframe><p>This is not the topic of this article, so that’s why I am not going into detail with CXF configuration. You just have to configure CXF like below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5373278d2f6348ed99842ff3599e8541/href">https://medium.com/media/5373278d2f6348ed99842ff3599e8541/href</a></iframe><p>Now, if I start my Spring Boot application, I can reach WSDL of my simple web service like this: http://localhost:8080/ws/helloWorldWS?wsdl</p><p>I will just write a test class to test my simple web service as below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac37c698c808f54b72e5156fde1404cf/href">https://medium.com/media/ac37c698c808f54b72e5156fde1404cf/href</a></iframe><p>As I run it, I see the below output. My web service works, now let’s get to the point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dwF-KTQAf2nMVUuJYHxb0A.png" /></figure><h3>Web Service Client Consumer Configuration</h3><p>If you like, you can start a new project like the previous one to consume the HelloWorld web service. Before consuming a web service, I need a client jar file. I am going to use <strong><em>wsimport</em></strong> utility to create a client jar file, with a command like this;</p><p><em>wsimport -clientjar helloWorldWSClient.jar “http://localhost:8080/ws/helloWorldWS?wsdl&quot;</em></p><p>Client jar is created and I need to add it to the project as a dependency. After that, I can create a CXF configuration for it like below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5b9813b90d5e4a7ee832c9e394ec96d/href">https://medium.com/media/b5b9813b90d5e4a7ee832c9e394ec96d/href</a></iframe><p>I created a bean name as helloWorldWSClient, as you see. HelloWorldWS.class is the service class included in the client jar file. WSDL location is the path of the WSDL file in the jar file. serviceName consists of namespace and port name. You can put some configuration parameters into the properties map (like connection and socket timeout values). And the last thing to do is to set the endpoint of the service.</p><p>The<em> </em>LoggingFeature is required to log outgoing requests and incoming responses. If you want to log them you just have to put the below line into the application.properties file:</p><p><em>logging.level.org.apache.cxf.services = INFO</em></p><p>This will cause all CXF clients to log requests and responses. If you want to log only a specific service, then you need to have log configs like below.</p><p><em>logging.level.org.apache.cxf.services.HelloWorldWS.REQ_OUT = INFO</em></p><p><em>logging.level.org.apache.cxf.services.HelloWorldWS.RESP_IN = INFO</em></p><p>As it is obvious, you can use the service class name to log a specific service.</p><h3>Consumer Web Service</h3><p>Once the configuration is done, I am ready to call and consume our soap service. First of all, I am going to create a consumer service like below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/611b58438c51801fee73428df09e9c51/href">https://medium.com/media/611b58438c51801fee73428df09e9c51/href</a></iframe><p>Now, I need to test this consumer service. I am going to write a simple test class with a simple assertion.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/72707a7b9d7751ff7c956a28b6464009/href">https://medium.com/media/72707a7b9d7751ff7c956a28b6464009/href</a></iframe><p>After running this test, let’s look at the console output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rqcj1Gm7sAKFS_9t1TwQIw.png" /></figure><p>That’s all.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5dce25a553" width="1" height="1" alt=""><hr><p><a href="https://medium.com/turkcell/consuming-soap-service-with-apache-cxf-and-spring-5dce25a553">Consuming SOAP Service With Apache CXF and Spring</a> was originally published in <a href="https://medium.com/turkcell">turkcell</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>