当前位置: 首页 > news >正文

域名注册管理机构seo多久可以学会

域名注册管理机构,seo多久可以学会,wordpress 手机菜单栏,企业网站建设有什么要求Web Services 是不是过时了#xff1f; 今天是兔年最后一天#xff0c;先给大家拜个早年 。 昨天上午视频面试一家公司需要开发Web Services 服务#xff0c;这个也没有什么#xff0c;但还需要用 VB.net 开发。这个是多古老的语言了#xff0c;让我想起来了 10年 前 写 …Web Services 是不是过时了 今天是兔年最后一天先给大家拜个早年 。 昨天上午视频面试一家公司需要开发Web Services 服务这个也没有什么但还需要用 VB.net 开发。这个是多古老的语言了让我想起来了 10年 前 写 VBA 的时候那就写了一个玩玩 文章目录 Web Services 是不是过时了前言一、准备工作二、基本配置步骤1.选择 web 服务 asmx 服务2.引用 mysql package3.web.config 文件加入数据库connectionString4.然后写一个 select 的方法5.方法改造 XML序列化6.写一个带参数的7.写一个 Insert的方法8.最后疑问Web Services 和Web API 那个运用的更广泛呢 总结 前言 网上百度了下基础知识大家了解下 选择使用 Web Services 还是 Web API 取决于您的具体需求和技术栈。这两者都是用于实现分布式系统和服务的技术但它们有一些区别。 Web Services: SOAP (Simple Object Access Protocol): Web Services 常基于 SOAP 协议这是一种使用 XML 格式进行通信的协议。 协议和标准: Web Services 通常严格遵循一系列协议和标准如 WSDL (Web Services Description Language) 用于描述服务UDDI (Universal Description, Discovery, and Integration) 用于服务的发现。 跨语言性: 由于使用了标准化的协议和格式Web Services 可以在不同平台和语言之间进行通信。 Web API: RESTful (Representational State Transfer): Web API 常基于 RESTful 架构使用 JSON 或 XML 进行数据传输。 轻量级: 相对于 Web ServicesWeb API 更轻量级通常使用 HTTP 协议进行通信不像 Web Services 那样依赖较多的协议和标准。 更简单: Web API 更简单易用通常适合构建基于 HTTP 的轻量级服务特别是在移动应用和单页应用中。 一、准备工作 上午查了一些资料 需要安装 mysql 数据库 8.0 需要安装 Microsoft Visual Studio Professional 2022 vb.net 需要安装 IIS 服务 需要安装 mysql-connector-net-8.3.0 库 自己的 系统是 windows 10 好了基本就些就是开发环境了 二、基本配置步骤 1.选择 web 服务 asmx 服务 2.引用 mysql package 下载地址 https://dev.mysql.com/downloads/connector/net/ 需要先安装 mysql 驱动 然后选择 dll 应用 最后 本code 使用是网上的 classicmodels 数据库 可以去下载 classicmodels 数据库具体如下 点击classicmodels 也可以去 下面我的博客资源下载 https://download.csdn.net/download/tomxjc/88685970 用的是 MySQL 8.0 3.web.config 文件加入数据库connectionString 主要就是加入 这段 ?xml version1.0 encodingutf-8? !--有关如何配置 ASP.NET 应用程序的详细信息请访问https://go.microsoft.com/fwlink/?LinkId169433 -- configurationconnectionStringsadd nameMySqlConnectionconnectionStringServerlocalhost;Databaseclassicmodels;User Idroot;Password123456;providerNameMySql.Data.MySqlClient //connectionStringssystem.webcompilation debugtrue strictfalse explicittrue targetFramework4.7.2 /httpRuntime targetFramework4.7.2 //system.websystem.codedomcompilerscompiler languagec#;cs;csharp extension.cs typeMicrosoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version2.0.1.0, Cultureneutral, PublicKeyToken31bf3856ad364e35 warningLevel4 compilerOptions/langversion:default /nowarn:1659;1699;1701 /compiler languagevb;vbs;visualbasic;vbscript extension.vb typeMicrosoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version2.0.1.0, Cultureneutral, PublicKeyToken31bf3856ad364e35 warningLevel4 compilerOptions/langversion:default /nowarn:41008 /define:_MYTYPE\quot;Web\quot; /optionInfer //compilers/system.codedom /configuration在 vb 中调用的语法是 Public connectionString As String ConfigurationManager.ConnectionStrings(MySqlConnection).ConnectionString4.然后写一个 select 的方法 WebMethod()Public Function QueryDatabase() As StringDim result As String TryUsing connection As New MySqlConnection(connectionString)connection.Open() Specify your MySQL queryDim query As String SELECT * FROM Products where Classic Cars Execute the queryUsing command As New MySqlCommand(query, connection)Using reader As MySqlDataReader command.ExecuteReader()Dim xmlResult As New XmlDocument() Create the root elementDim rootElement As XmlElement xmlResult.CreateElement(Data)xmlResult.AppendChild(rootElement)While reader.Read() Create individual data elementsDim dataElement As XmlElement xmlResult.CreateElement(Item)Dim idElement As XmlElement xmlResult.CreateElement(productCode)idElement.InnerText reader(productCode).ToString()dataElement.AppendChild(idElement)Dim nameElement As XmlElement xmlResult.CreateElement(productName)nameElement.InnerText reader(productName).ToString()dataElement.AppendChild(nameElement)Dim lineElement As XmlElement xmlResult.CreateElement(productline)lineElement.InnerText reader(productline).ToString()dataElement.AppendChild(lineElement)Dim descElement As XmlElement xmlResult.CreateElement(productDescription)descElement.InnerText reader(productDescription).ToString()dataElement.AppendChild(descElement)rootElement.AppendChild(dataElement)End Whileresult xmlResult.OuterXmlEnd UsingEnd UsingEnd UsingCatch ex As Exception Handle exceptionsresult $Error{ex.Message}/ErrorEnd TryReturn resultEnd Function验证数据 结果返回是这样返回是 字符类型不是应该自动识别的吗看来是没有XML序列化 5.方法改造 XML序列化 WebMethod()Public Function QueryDatabaseXmlSerializer() As XmlDocument这个表代码XML序列化 并返回 XmlDocument 类型Dim xmlDoc As New XmlDocument()TryUsing connection As New MySqlConnection(connectionString)connection.Open() Specify your MySQL queryDim query As String SELECT * FROM Products WHERE productline Classic Cars Execute the queryUsing command As New MySqlCommand(query, connection)Using reader As MySqlDataReader command.ExecuteReader()Dim items As New List(Of Products)()While reader.Read() Create instances of the Item class and populate themDim item As New Products() With {.productCode reader(productCode).ToString(),.productName reader(productName).ToString(),.productline reader(productline).ToString(),.productDescription reader(productDescription).ToString()}items.Add(item)End While Serialize the list of items to XMLDim serializer As New XmlSerializer(GetType(List(Of Products)))Using writer As XmlWriter xmlDoc.CreateNavigator().AppendChild()serializer.Serialize(writer, items)End UsingEnd UsingEnd UsingEnd UsingReturn xmlDocCatch ex As Exception Handle exceptionsDim errorDoc As New XmlDocument()errorDoc.LoadXml($Error{ex.Message}/Error)Return errorDocEnd TryEnd Function在加入一个类 Public Class ProductsPublic Property productCode As StringPublic Property productName As StringPublic Property productDescription As StringPublic Property productline As String End Class再验证一下 6.写一个带参数的 WebMethod() Public Function QueryProductByCodeXmlSerializer(productCode As String) As XmlDocumentDim xmlDoc As New XmlDocument()TryUsing connection As New MySqlConnection(connectionString)connection.Open() Specify your MySQL query with a parameterDim query As String SELECT * FROM Products WHERE productCode ProductCode Execute the queryUsing command As New MySqlCommand(query, connection) Add the parameter to the commandcommand.Parameters.AddWithValue(ProductCode, productCode)Using reader As MySqlDataReader command.ExecuteReader()Dim items As New List(Of Products)()While reader.Read() Create instances of the Products class and populate themDim item As New Products() With {.productCode reader(productCode).ToString(),.productName reader(productName).ToString(),.productline reader(productline).ToString(),.productDescription reader(productDescription).ToString()}items.Add(item)End While Serialize the list of items to XMLDim serializer As New XmlSerializer(GetType(List(Of Products)))Using writer As XmlWriter xmlDoc.CreateNavigator().AppendChild()serializer.Serialize(writer, items)End UsingEnd UsingEnd UsingEnd UsingReturn xmlDocCatch ex As Exception Handle exceptionsDim errorDoc As New XmlDocument()errorDoc.LoadXml($Error{ex.Message}/Error)Return errorDocEnd Try End Function验证数据 显示 7.写一个 Insert的方法 mysql 建表 CREATE TABLE china_city (citycode varchar(10) NOT NULL,city varchar(50) NOT NULL,PRIMARY KEY (citycode) ) ENGINEInnoDB DEFAULT CHARSETutf8mb4 COLLATEutf8mb4_0900_ai_ci;代码先写了 类 Public Class ChinaCityPublic Property CityCode As StringPublic Property City As String End ClassWebMethod() Public Function InsertCity(cityCode As String, cityName As String) As XmlDocumentDim errorDoc, successfulDoc As New XmlDocument()TryUsing connection As New MySqlConnection(connectionString)connection.Open() Specify your MySQL insert queryDim query As String INSERT INTO china_city (citycode, city) VALUES (CityCode, CityName) Execute the insert queryUsing command As New MySqlCommand(query, connection) Add parameters to the commandcommand.Parameters.AddWithValue(CityCode, cityCode)command.Parameters.AddWithValue(CityName, cityName) Execute the insert queryDim rowsAffected As Integer command.ExecuteNonQuery() Check if the insertion was successfulIf rowsAffected 0 ThensuccessfulDoc.LoadXml($ResultInsertion successful/Result)Return successfulDocElseerrorDoc.LoadXml($ErrorNo rows inserted/Error)Return errorDocEnd IfEnd UsingEnd UsingCatch ex As Exception Handle exceptionserrorDoc.LoadXml($Error{ex.Message}/Error)Return errorDocEnd Try End Function验证数据 8.最后疑问Web Services 和Web API 那个运用的更广泛呢 chatGPT 给出了答案 总结 以上源码下载如下https://download.csdn.net/download/tomxjc/88822612 好了今天就介绍到这里。希望大家喜欢 一键三连 福星高照
http://www.hkea.cn/news/14300749/

相关文章:

  • 网站页面设计论文东莞seo排名外包
  • 网站开发与运营方向和企业管理方向山东外贸网站建设怎么样
  • 怎么识别网站是用什么语言做的石家庄最好的网站建设公司
  • 安徽区块链虚拟币网站开发价格长沙优化网站多少钱
  • 做外贸做什么网站好门户网站模板之家
  • 凡科免费网站建设网站建设及第三方支付
  • 合肥做网站找哪家好wordpress 免费APP
  • 商城类网站用什么做什么网站能让小孩做算术题
  • 网站模型怎么做seo工作职位
  • php网站做退出的代码博客app下载安装
  • 西安做网站魔盒手机上怎么创建自己的网站
  • 阿里网站搭建wordpress 首页跳转
  • 企业网站维护合同网站更新步骤
  • 福州房地产网站建设如何建设彩票网站
  • c 做商务网站方便吗贵州城乡建设厅考试网站
  • 织梦cms建设企业网站学设计的视频网站
  • 济南市建设工程招标投标协会网站最近的新闻大事20条
  • 外贸网站建设 东莞灰色风格的网站
  • 学校网站建设状况宁波北仑网站网页建设
  • 企业网站建立流程的第一步是什么企业网站开发周期
  • 深圳市罗湖网站建设如何做一个网站的功能吗
  • 淘宝客怎么做直播网站吗亚马逊网站建设与维护方法分析
  • 建设行网站修改电话网站排名优化推广厦门
  • 南昌网站维护网页设计与制作课程内容
  • wordpress 默认主题站点北京企业网站建设推荐
  • 惠州市网站制作有限公司松岗做网站
  • 孝感网站推广广东企业网站seo报价
  • 义乌公司网站建设磐安住房和城乡建设部网站
  • title 网站建设网站建设需要哪些技术
  • 重生北京上大学开网吧做网站的小说广电基础设施建设官方网站