Giriş
Şu satırı dahil ederiz
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
Maven
Şu satırı dahil ederiz
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web-services</artifactId></dependency>
Açıklaması şöyle. WebServiceTemplate yazısına bakabilirsiniz
This is the central class for client-side Web services. It provides a message-driven approach to sending and receiving Spring WebServiceMessage instances.
getWebServiceTemplate metodu
Örnek
Şöyle yaparız
setDefaultUri metodupublic class ArticleClient extends WebServiceGatewaySupport {public GetArticleResponse getArticle(int id){GetArticleRequest getArticleRequest = new GetArticleRequest();getArticleRequest.setId(id);return (GetArticleResponse) getWebServiceTemplate()
.marshalSendAndReceive(getArticleRequest);}}
Şöyle yaparız
import org.springframework.oxm.jaxb.Jaxb2Marshaller;@Configurationpublic class SoapClientConfig {@Beanpublic Jaxb2Marshaller marshaller(){Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();jaxb2Marshaller.setContextPath("com.medium.article");return jaxb2Marshaller;}@Beanpublic ArticleClient articleClient(Jaxb2Marshaller jaxb2Marshaller) {ArticleClient articleClient = new ArticleClient();articleClient.setDefaultUri("http://localhost:8080/ws/article");articleClient.setMarshaller(jaxb2Marshaller);articleClient.setUnmarshaller(jaxb2Marshaller);return articleClient;}}
Hiç yorum yok:
Yorum Gönder