java使用spring RestTemplate 调用 webservice服务

本文介绍了如何在Spring Boot项目中利用RestTemplate调用WebService服务。讲解了配置RestTemplate、调用注入及解析结果的过程,并强调了在调用时应注意的细节,如URL不应包含?wsdl和需要对XML结果进行反转义。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

项目基础环境是spring boot的

spring boot相关知识不做详解

webservice 基本结构如下

webservice 基本结构

webservice 相关调试,获取请求参数可参考

参考

pom中不需要额外引用

  • 配置RestTemplateConfig
package com.xxxx.base.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

@Configuration
public class RestTemplateConfig {
    @Bean
    public RestTemplate restTemplate(ClientHttpRequestFactory factory) {
	return new RestTemplate(factory);
    }

    @Bean
    publ
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值