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.pswp.cn/news/36357.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/36357.shtml
英文地址,請注明出處:http://en.pswp.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…