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

公司网站是否做地方分站直销产业发展论坛

公司网站是否做地方分站,直销产业发展论坛,国内免费可商用图片素材网站,网站建设 上海珍岛原文:SOAP with TrinityCore | TrinityCore MMo Project Wiki 如何使用SOAP与TC交互 SOAP代表简单对象访问协议,是一种类似于REST的基于标准的web服务访问协议的旧形式。只要必要的配置到位,您就可以利用SOAP向TrinityCore服务器发送命令。 …

原文:SOAP with TrinityCore | TrinityCore MMo Project Wiki

 

如何使用SOAP与TC交互

SOAP代表简单对象访问协议,是一种类似于REST的基于标准的web服务访问协议的旧形式。只要必要的配置到位,您就可以利用SOAP向TrinityCore服务器发送命令。
理解SOAP的一个好方法是将其与当代REST进行比较。以下文章很好地解释了这一点——https://smartbear.com/blog/soap-vs-rest-whats-the-difference/.
两者之间的主要区别在于,SOAP完全依赖于XML来提供响应和接受有效载荷。PHP提供了一些使此过程更容易的方法,但根据您的使用情况,您可能需要熟悉XML。

配置


worldserver.conf
确保配置文件中的设置设置正确。

#    SOAP.Enable
#        Description: Enable soap service.
#        Default:     0 - (Disabled)
#                     1 - (Enabled)
SOAP.Enabled = 1#    SOAP.IP
#        Description: Bind SOAP service to IP/hostname.
#        Default:     "127.0.0.1" - (Bind to localhost)
SOAP.IP = "127.0.0.1"#    SOAP.Port
#        Description: TCP port to reach the SOAP service.
#        Default:     7878
SOAP.Port = 7878

考虑到您的特定RBAC访问配置,您还需要一个有权使用GM命令的用户帐户。专门为此目的创建一个受限访问帐户,而不是一个人使用的帐户,这可能是一个好主意。

注意:在撰写本文时,TC 335a仅支持HTTP,因此请注意不要以这种方式发送机密(密码等)。假设传递的任何内容都是明文形式,任何人都可以阅读。
如果您计划通过SOAP远程连接,您绝对应该采取措施确保安全连接。一种潜在的方法是通过apache或nginx通过反向SSL代理。但是,这不在本指南的范围内,将不包括在内。

用于原型制作的HTTP客户端


有一些客户端可以快速建立连接并测试控制台命令:
postman:https://www.postman.com/(网络、桌面代理/客户端)
insomnia:https://insomnia.rest/
夜莺nightingale:https://nightingale.rest/
它们都提供了各种各样的细节,但最终的工作原理大致相同。感谢Jackpoz为Postman提供的具体步骤-https://www.postman.com/.
Postman有两种风格:web界面(以及可以安装以执行localhost请求的代理)和完全客户端桌面应用程序。这两种情况下的说明是相同的。
在“我的工作区”下,找到“导入”按钮。您将使用原始文本选项。
将以下JSON复制并粘贴到文本框中。请确保将item.request.auth.basic下的凭据更新为前面提到的GM用户。

{"info": {"name": "TC SOAP","schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"},"item": [{"name": "server info","request": {"auth": {"type": "basic","basic": {"username": "CHANGEME","password": "CHANGEME","showPassword": false}},"method": "POST","header": [],"body": {"mode": "raw","raw": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns1=\"urn:TC\">\r\n<SOAP-ENV:Body>\r\n<ns1:executeCommand>\r\n<command>server info</command>\r\n</ns1:executeCommand>\r\n</SOAP-ENV:Body>\r\n</SOAP-ENV:Envelope>","options": {"raw": {"language": "xml"}}},"url": "http://127.0.0.1:7878"},"response": []}]
}

您应该将TC SOAP视为要导入的集合。单击“导入”。
这将使用正确的HTTP方法(POST)以及“授权”和“正文”选项卡下的详细信息填充新集合。
在Body选项卡下,注意XML负载和为您预先填充的服务器信息命令。
单击“发送”按钮将提交请求,并提供XML响应。
在Postman界面的右侧,一个</>符号将打开代码片段,可以将请求转换为您选择的语言。
¶使用PHP
要使用PHP与TrinityCore交互,您需要确保安装了PHP-soap扩展。还要确保您使用的是仍在积极支持的PHP版本。代码示例在PHP7.4到PHP8.1上进行了测试。
在所有这些示例中,urn:TC URI都是必需的参数,因为我们没有提供WSDL文档。
SoapClient-https://www.php.net/manual/en/class.soapclient.php

$command  = 'server info';$opts = ['http' => ['header' => "Authorization: Basic " . base64_encode("USERNAME:PASSWORD")]];$client = new SoapClient($wsdl = null, ['stream_context' => stream_context_create($opts),'location' => 'http://127.0.0.1:7878','uri' => 'urn:TC',
]);try {$result = $client->executeCommand(new SoapParam($command, 'command'));
} catch (\Exception $e) {die($e->getMessage());
}echo $result;

Note that we are passing a HTTP basic authorization header with base64 encoded username and password (separated by a colon). Alternatively, you could omit the stream_context parameter, and instead include a (login) username and password in your SoapClient configuration.

$command  = 'server info';$client = new SoapClient($wsdl = null, ['location' => 'http://127.0.0.1:7878','uri' => 'urn:TC','login' => 'USERNAME','password' => 'PASSWORD',
]);try {$result = $client->executeCommand(new SoapParam($command, 'command'));
} catch (Exception $e) {die($e->getMessage());
}echo $result;

Either approach is fine - but don't be fooled! Base 64 encoding does not inherently make it more secure.

Remember that the SOAP client can only recognize failures to connect, or misconfigurations. It will not know if you've provided an invalid command. So it's up to you to parse the results and decide if the intended result was a success or not. Output will be just as if you performed the command on the console.

Lastly, if you'd rather not rely on the SOAP extension or client, you can form the XML payload and parse the resulting XML response yourself. You'll still need the cURL extension, but this is usually available if not enabled by default.

<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelopexmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"xmlns:ns1="urn:TC"><SOAP-ENV:Body><ns1:executeCommand><command>server info</command></ns1:executeCommand></SOAP-ENV:Body>
</SOAP-ENV:Envelope>
$curl = curl_init();curl_setopt_array($curl, [CURLOPT_POSTFIELDS => $payload, // $payload is the XML provided aboveCURLOPT_URL => 'http://127.0.0.1:7878',CURLOPT_TIMEOUT => 0,CURLOPT_CUSTOMREQUEST => 'POST',CURLOPT_HTTPHEADER => ["Authorization: Basic " . base64_encode("{$user}:{$pass}"),'Content-Type: application/xml',],
]);$response = curl_exec($curl);
curl_close($curl);
echo $response;

 

 

http://www.tj-hxxt.cn/news/63018.html

相关文章:

  • 给漫画网站做推广网页模版
  • 湖南好搜网站建设windows优化大师使用方法
  • 阳谷做网站上海网络关键词优化
  • 网站建设学什么语音百度seo技术优化
  • 做网站开发的过程武汉网络广告推广服务
  • 深圳网站建设服务联系方式公司网站建设平台
  • 文昌市建设局网站seo网站关键词优化快速官网
  • 做网站用html好还是vue好网络营销五种方法
  • 台州seo推广公司百度关键词优化多久上首页
  • 红酒网站建设方案b2b平台排名
  • 做外围什么网站有客户洛阳网站建设优化
  • 青岛做网站大公司有哪些成都网站关键词排名
  • 大型的PC网站适合vue做吗网络运营需要学什么
  • 自己做网站一定要实名吗手机打开国外网站app
  • 一级域名 二级域名 目录网站推广全网网络营销
  • 电视台网站如何做新闻报道自己开网店怎么运营
  • 网站favicon.ico 大小seo诊断分析在线工具
  • 政府网站建设立规矩营销型网站设计制作
  • 营销型网站建设大千建站国家高新技术企业查询
  • 深圳模板开发建站百度移动排名优化软件
  • 电子商务网站设计与实现常州seo排名收费
  • 上海装修公司报价明细表sem和seo哪个工作好
  • mysql 连接wordpress郑州seo顾问外包公司
  • 大学生做简历的网站培训机构排名
  • phyton 网站开发sem是什么的缩写
  • 网站建设走无形资产网站搜索
  • 怎样做免费网站网址收录大全
  • 黄埔做网站的公长春关键词优化排名
  • 网站建设及报价网站建设公司排名
  • 荔湾建网站公司福建seo快速排名优化