soap通信2

首先,定义一个XSD(XML Schema Definition)来描述你的数据结构。在你的Maven项目的src/main/resources目录下,创建一个名为schemas的文件夹,并在其中创建一个名为scriptService.xsd的文件,内容如下:

scriptService.wsdl

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"xmlns:tns="http://yournamespace.com"targetNamespace="http://yournamespace.com"><wsdl:types><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"targetNamespace="http://yournamespace.com"xmlns="http://yournamespace.com"elementFormDefault="qualified"><!-- Import the XSD schema --><xs:import namespace="http://yournamespace.com" schemaLocation="scriptService.xsd"/><!-- Define input and output message elements --><xs:element name="ExecuteScriptRequest" type="tns:ScriptInfo"/><xs:element name="ExecuteScriptResponse" type="tns:ScriptResult"/></xs:schema></wsdl:types><!-- Define the portType --><wsdl:portType name="ScriptServicePortType"><wsdl:operation name="ExecuteScript"><wsdl:input message="tns:ExecuteScriptRequest"/><wsdl:output message="tns:ExecuteScriptResponse"/></wsdl:operation></wsdl:portType><!-- Define the binding --><wsdl:binding name="ScriptServiceBinding" type="tns:ScriptServicePortType"><wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/><wsdl:operation name="ExecuteScript"><wsdl:input><wsdlsoap:body use="literal"/></wsdl:input><wsdl:output><wsdlsoap:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><!-- Define the service --><wsdl:service name="ScriptService"><wsdl:port name="ScriptServicePort" binding="tns:ScriptServiceBinding"><wsdlsoap:address location="http://your-service-endpoint"/></wsdl:port></wsdl:service>
</wsdl:definitions>

然后,创建一个名为scriptService.wsdl的WSDL文件,也在schemas文件夹中,内容如下:

scriptService.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"targetNamespace="http://yournamespace.com"xmlns="http://yournamespace.com"elementFormDefault="qualified"><xs:complexType name="ScriptInfo"><xs:sequence><xs:element name="projectName" type="xs:string"/><xs:element name="scriptName" type="xs:string"/><xs:element name="args01" type="xs:string"/></xs:sequence></xs:complexType><xs:complexType name="ScriptResult"><xs:sequence><xs:element name="executionId" type="xs:string"/><xs:element name="exitStatus" type="xs:int"/><xs:element name="timestamp" type="xs:dateTime"/></xs:sequence></xs:complexType><xs:element name="ScriptRequest" type="ScriptInfo"/><xs:element name="ScriptResponse" type="ScriptResult"/>
</xs:schema>

创建一个用于定义SOAP服务的Endpoint类。这个类将会处理SOAP请求和响应。

SoapEndpoint.java

import org.springframework.ws.server.endpoint.annotation.*;@Endpoint
public class SoapEndpoint {private static final String NAMESPACE_URI = "http://yournamespace.com";@PayloadRoot(namespace = NAMESPACE_URI, localPart = "ExecuteScriptRequest")@ResponsePayloadpublic ExecuteScriptResponse executeScript(@RequestPayload ExecuteScriptRequest request) {// 处理请求并生成响应ExecuteScriptResponse response = new ExecuteScriptResponse();ScriptResult scriptResult = new ScriptResult();// 设置响应内容response.setScriptResult(scriptResult);return response;}
}

接下来,创建一个配置类,用于配置Spring Web Services。

Spring Web Services.java

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.ws.config.annotation.EnableWs;
import org.springframework.ws.config.annotation.WsConfigurerAdapter;
import org.springframework.ws.soap.server.endpoint.interceptor.PayloadLoggingInterceptor;
import org.springframework.ws.transport.http.MessageDispatcherServlet;@EnableWs
@Configuration
public class WebServiceConfig extends WsConfigurerAdapter {@Beanpublic ServletRegistrationBean<MessageDispatcherServlet> messageDispatcherServlet(ApplicationContext applicationContext) {MessageDispatcherServlet servlet = new MessageDispatcherServlet();servlet.setApplicationContext(applicationContext);servlet.setTransformWsdlLocations(true);return new ServletRegistrationBean<>(servlet, "/ws/*");}@Beanpublic PayloadLoggingInterceptor payloadLoggingInterceptor() {return new PayloadLoggingInterceptor();}
}

application.properties

spring.webservices.mapping.path=/ws
spring.webservices.servlet.init.wsdlPath=classpath:/schemas/scriptService.wsdl

application.yml

server:port: 8080spring:webservices:mapping:path: /wsservlet:init:wsdlPath: classpath:/schemas/scriptService.wsdl

在这个示例中,我们配置了服务器端口为8080,映射了SOAP服务的路径为/ws。同时,我们指定了WSDL文件的路径为classpath:/schemas/scriptService.wsdl,这意味着WSDL文件应该放在src/main/resources/schemas目录下。

如果你有其他需要配置的属性,你可以在这个application.yml文件中添加。记得根据你的实际项目情况来进行相应的配置。

请确保修改命名空间、路径和其他属性,以便与你的项目和数据结构匹配。配置完成后,当你启动应用程序时,它将使用这些配置项来设置Spring Boot SOAP服务。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/36357.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【kubernetes】调度约束

目录 调度约束 Pod 启动典型创建过程如下 调度过程 指定调度节点 查看详细事件&#xff08;发现未经过 scheduler 调度分配&#xff09; 获取标签帮助 需要获取 node 上的 NAME 名称 给对应的 node 设置标签分别为 ggls 和 gglm 查看标签 修改成 nodeSelector 调度方…

vue学习笔记

1.官网 v2官网 https://v2.cn.vuejs.org/ v3官网 https://cn.vuejs.org/ 2.vue引入 在线引入 <script src"https://cdn.jsdelivr.net/npm/vue2.7.14/dist/vue.js"></script> 下载引入(下载链接) https://v2.cn.vuejs.org/js/vue.js 3.初始化渲…

Redis——通用命令介绍

Redis官方文档 redis官方文档 核心命令 set 将key和value存储到Redis中&#xff0c;key和value都是字符串 set key valueRedis中不区分大小写&#xff0c;字符串类型也不需要添加单引号或者双引号 get 根据key读取value&#xff0c;如果当前key不存在&#xff0c;则返回…

Offset Explorer

Offset Explorer 简介下载安装 简介 Offset Explorer&#xff08;以前称为Kafka Tool&#xff09;是一个用于管理和使Apache Kafka 集群的GUI应用程序。它提供了一个直观的UI&#xff0c;允许人们快速查看Kafka集群中的对象以及存储在集群主题中的消息。它包含面向开发人员和管…

RANSAC算法

RANSAC简介 RANSAC(RAndom SAmple Consensus,随机采样一致)算法是从一组含有“外点”(outliers)的数据中正确估计数学模型参数的迭代算法。 “外点”一般指的的数据中的噪声&#xff0c;比如说匹配中的误匹配和估计曲线中的离群点。所以&#xff0c;RANSAC也是一种“外点”检…

若依-plus-vue启动显示Redis连接错误

用的Redis是windows版本&#xff0c;6.2.6 报错的主要信息如下&#xff1a; Failed to instantiate [org.redisson.api.RedissonClient]: Factory method redisson threw exception; nested exception is org.redisson.client.RedisConnectionException: Unable to connect t…

基于epoll的TCP服务器端(C++)

网络编程——C实现socket通信(TCP)高并发之epoll模式_tcp通信c 多客户端epoll_n大橘为重n的博客-CSDN博客 网络编程——C实现socket通信(TCP)高并发之select模式_n大橘为重n的博客-CSDN博客 server.cpp #include <stdio.h> #include <sys/types.h> #include <…

Coin Change

一、题目 Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent. We want to make changes with these coins for a given amount of money. For example, if we have 11 cents, then we can make changes with one 10-cent coin and one 1-c…

springboot工程使用阿里云OSS传输文件

在application.yml文件中引入对应的配置&#xff0c;一个是对应的节点&#xff0c;两个是密钥和账号&#xff0c;还有一个是对应文件的名称&#xff1b; 采用这样方式进行解耦&#xff0c;便于后期修改。 然后需要设置一个properties类&#xff0c;去读对应的配置信息 用到了…

MySQL Linux自建环境备份至远端服务器自定义保留天数

环境准备 linux下安装mysql请看 Linux环境安装单节点mysql8.0.16 系统版本: CentOS 7 软件版本: mysql8.0.16 备份策略与实现方法 此次备份依赖mysql自带命令mysqldump与linux下crontab命令(定时任务) mysqldump mysqldump客户实用程序执行 逻辑备份,产生一组能够被执行…

为什么需要知识图谱,如何构建它?

从关系数据库迁移到图形数据库的指南 跟随 发表于 迈向数据科学 7 分钟阅读 4天前 154 4 一、说明 TLDR&#xff1a;知识图谱在图数据库中组织事件、人员、资源和文档&#xff0c;以进行高级分析。本文将解释知识图谱的用途&#xff0c;并向您展示如何将关系数据模型转换为图…

HTTP协议的发展过程

前言 HTTP协议是一种用于在网络上传输信息的应用层协议&#xff0c;它为万维网的运作提供了基础。 最早的版本是HTTP/0.9&#xff0c;它是HTTP协议的第一个版本&#xff0c;诞生于1991年&#xff0c;其设计初衷是为了在计算机之间传输简单的超文本文档&#xff0c;即HTML。 在…

在Java中对XML的简单应用

XML 数据传输格式1 XML 概述1.1 什么是 XML1.2 XML 与 HTML 的主要差异1.3 XML 不是对 HTML 的替代 2 XML 语法2.1 基本语法2.2 快速入门2.3 组成部分2.3.1 文档声明格式属性 2.3.2 指令&#xff08;了解&#xff09;&#xff1a;结合CSS2.3.3 元素2.3.4 属性**XML 元素 vs. 属…

【Linux】Linux中获取UUID的方法

1、从mmc块设备获取 在Linux下,获取MMC的CID(Card Identification,识别ID) cat /sys/block/mmcblk0/device/cidMMC CID组成 MID: [127:120] —— 8bit(1Byte)Manufacturer ID,由MMCA分配,比如Sandisk为0x02,Kingston为0x37,Samsung为0x15。OID: [119:104] —— 16b…

windows程序基础

一、windows程序基础 1. Windows程序的特点 1&#xff09;用户界面统一、友好 2&#xff09;支持多任务:允许用户同时运行多个应用程序(窗口) 3&#xff09;独立于设备的图形操作 使用图形设备接口( GDI, Graphics Device Interface )屏蔽了不同硬件设备的差异&#…

什么是视频的编码和解码

这段描述中&#xff0c;视频解码能力和视频编码能力指的是不同的处理过程。视频解码是将压缩过的视频数据解开并还原为可播放的视频流&#xff0c;而视频编码是将原始视频数据压缩成更小的尺寸&#xff0c;以减少存储空间和传输带宽。在这个上下文中&#xff0c;解码能力和编码…

LVGL学习笔记 30 - List(列表)

目录 1. 添加文本 2. 添加按钮 3. 事件 4. 修改样式 4.1 背景色 4.2 改变项的颜色 列表是一个垂直布局的矩形&#xff0c;可以向其中添加按钮和文本。 lv_obj_t* list1 lv_list_create(lv_scr_act());lv_obj_set_size(list1, 180, 220);lv_obj_center(list1); 部件包含&…

Android:换肤框架Android-Skin-Support

gihub地址&#xff1a;https://github.com/ximsfei/Android-skin-support 样例&#xff1a; 默认&#xff1a; 更换后&#xff1a; 一、引入依赖&#xff1a; // -- 换肤依赖implementation skin.support:skin-support:4.0.5// skin-supportimplementation skin.support:ski…

Rust语法:变量,函数,控制流,struct

文章目录 变量可变与不可变变量变量与常量变量的Shadowing标量类型整数 复合类型 函数控制流if elseloop & whilefor in structstruct的定义Tuple Structstruct的方法与函数 变量 可变与不可变变量 Rust中使用let来声明变量&#xff0c;但是let声明的是不可变变量&#x…

Golang自定义类型与类型别名

type myInt int32 与 type myInt int32&#xff0c;概念并不相同 自定义类型&#xff1a;type myInt int32 通过这种方式定义的类型是一个全新的类型&#xff0c;这个新类型与int32有相同的底层结构&#xff0c;但是却与int32类型不兼容。 type myInt int32var a int32 5 var…