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

自己装修设计软件seo门户网价格是多少钱

自己装修设计软件,seo门户网价格是多少钱,网站导航的重要性,wordpress 弹窗一、问题说明 1.1 问题描述 使用C# 搭建WebService接口,并按照ESB平台人员的要求,将命名空间改为"http://esb.webservice",使用PostmanESB平台人员提供的入参示例进行测试时,callBussiness接口参数message始终为null。 以下是ES…

一、问题说明

1.1 问题描述

使用C# 搭建WebService接口,并按照ESB平台人员的要求,将命名空间改为"http://esb.webservice",使用Postman+ESB平台人员提供的入参示例进行测试时,callBussiness接口参数message始终为null

以下是ESB平台提供的模版

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:esb="http://esb.webservice"><soapenv:Header/><soapenv:Body><esb:callBussiness><!--Optional:--><message><![CDATA[...]]></message></esb:callBussiness></soapenv:Body>
</soapenv:Envelope>

1.2 C# WebService代码

using System;
using System.IO;
using System.Text;
using System.Web.Services;
using System.Xml;
using System.Xml.Serialization;
using Rss_WebServer.code;namespace ESB
{/// <summary>/// WebService 的摘要说明/// </summary>[WebService(Namespace = "http://esb.webservice")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)][System.ComponentModel.ToolboxItem(false)]// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。 // [System.Web.Script.Services.ScriptService]public class WebService : System.Web.Services.WebService{[WebMethod(Description = "调用业务")]public string callBussiness(string message){return message; }}
}

1.3 Postman 测试参数

  • POST http://localhost:55305/WebService.asmx?op=callBussiness
  • Headers
KEYVALUEDESCRIPTION
Content-Typetext/xml; charset=utf-8
SOAPAction“http://esb.webservice/callBussiness”
  • Body
    • raw XML(text/xml)
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:esb="http://esb.webservice"><soapenv:Header/><soapenv:Body><esb:callBussiness><!--Optional:--><message><![CDATA[<root><author>少莫千华</author><email>370763160@qq.com</email></root>]]></message></esb:callBussiness></soapenv:Body>
</soapenv:Envelope>

在这里插入图片描述

在这里插入图片描述

二、问题分析

根本问题是ESB平台提供的参数模版并没有完全按照标准的WebService协议进行编写,导致使用官方搭建的WebService接口无法正常的解析参数,所以要想解决此问题,有两个途径:

  • 与ESB平台人员沟通,要求其标准化参数模版
  • 自己重新解构WebService参数

三、解决方案

3.1 与ESB平台人员沟通,要求其标准化参数模版

3.1.1 标准模版 - 使用命名空间缩写

callBussiness接口的message参数添加命名空间缩写esb

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:esb="http://esb.webservice"><soapenv:Header/><soapenv:Body><esb:callBussiness><!--Optional:--><esb:message><![CDATA[...]]></esb:message></esb:callBussiness></soapenv:Body>
</soapenv:Envelope>

3.1.1 标准模版 - 使用完整的命名空间

callBussiness接口的使用完整的命名空间<callBussiness xmlns="http://esb.webservice">

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header/><soapenv:Body><callBussiness xmlns="http://esb.webservice"><!--Optional:--><message><![CDATA[...]]></message></callBussiness></soapenv:Body>
</soapenv:Envelope>

3.2 自己重新解构WebService参数

从请求对象base.Context.Request中重新获取所有Body内容(InputStream),然后再进行自定义解析。
:因为是搭建的标准的WebService接口Body内容(InputStream)在进去函数内部前已经被SOAP协议解析过一次,所以InputStream起始内容位置Position 指向数据流的结尾,所以在读取之前,先要将InputStream起始内容位置Position设置为0,否则读取的内容为空('')

using System;
using System.IO;
using System.Text;
using System.Web.Services;
using System.Xml;
using System.Xml.Serialization;
using Rss_WebServer.code;
namespace ESB
{/// <summary>/// WebService 的摘要说明/// </summary>[WebService(Namespace = "http://esb.webservice")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)][System.ComponentModel.ToolboxItem(false)]// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。 // [System.Web.Script.Services.ScriptService]public class WebService : System.Web.Services.WebService{[WebMethod(Description = "调用业务")]public string callBussiness(string message){try{if (string.IsNullOrEmpty(message)){message = WebServiceAnalysis(base.Context.Request, nameof(message));}return message;}catch(Exception exp){return exp.Message;}}/// <summary>/// 重新解析 WebService/// </summary>/// <param name="request"></param>/// <param name="name"></param>/// <returns></returns>private string WebServiceAnalysis(System.Web.HttpRequest request,string name){try{if(request.ContentLength == 0){throw new Exception($"Body(xml数据) 无数据");}// 获取请求内容Stream inputStream = request.InputStream;// 重新获取内容inputStream.Position = 0;// 读取请求主体内容using (StreamReader reader = new StreamReader(inputStream, Encoding.UTF8)){string requestBody = reader.ReadToEnd();XmlDocument xmlDoc = new XmlDocument();xmlDoc.LoadXml(requestBody);XmlNode strNode = xmlDoc.SelectSingleNode($"//{name}");if (strNode != null){return strNode.InnerText;}else{throw new Exception($"未在Body(xml数据)找到{name}节点");}}}catch(Exception exp){throw exp;}}}
}
http://www.yidumall.com/news/18740.html

相关文章:

  • 只会前端可以做动态网站吗朋友圈软文范例
  • .net asp可以外链其它网站吗营销型网站建设的5大技巧
  • 网站应该怎么建设整合营销包括哪些内容
  • 扶贫网站建设优势免费网站怎么做出来的
  • 无锡抛无锡网站建设广场推广赚钱app哪个靠谱
  • 厦门建设银行招聘网站整站优化服务
  • 九亭做网站公司武汉整站优化
  • 现代网站开发设计报告百度收录检测
  • 平面设计必备软件刷排名seo软件
  • 域名解析到别人网站旺道seo系统
  • 域名注册那个网站的好线上推广有哪些渠道
  • 做静态网站接单怎么自己建网站
  • 常州武进网站建设seo简单优化操作步骤
  • 上海有多少个网站科技公司郑州网络推广大包
  • 做58推广网站找哪家好今日国内热点新闻头条事件
  • 建设学院网站的意义专门代写平台
  • 写作网站云自媒体服务平台
  • 开发什么网站好打开百度搜索
  • 论坛网站备案流程图百度怎么优化网站排名
  • 有机蔬菜哪个网站做的更好公司网站建设费
  • 客户端网站建设文档产品推广方案范文500字
  • 上线了怎么建网站全球搜索
  • 高端网站建设 引擎技好的竞价托管公司
  • 查看网站架构神马快速排名优化工具
  • 吃什么补肾气效果好湘潭seo培训
  • 重庆网站设计最佳科技软文推广产品
  • 室内设计者联盟网站seo网站优化推广怎么样
  • 营销型网站建设有哪些特点福州seo视频
  • 简述网站的制作流程河南省郑州市金水区
  • 自己做的网站显示不全百度产品推广