SqlServer存储过程触发HTTP请求
WMS出库复核调用本质上就是一个HTTP请求,所以我们可以利用sqlserver的存储过程来触发一个HTTP请求来达到WMS出库复核触发接口一样的效果
使用此方式可以处理部分WMS版本无法配置出库复核摸板调用接口获取快递单号的情况
启动 OLE Automation Procedures
1 2
| sp_configure 'show advanced options', 1; --此选项用来显示sp_configure系统存储过程高级选项,当其值为1时,可以使用sp_configure列出高级选项。默认为0;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| GO
RECONFIGURE WITH OVERRIDE;
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE WITH OVERRIDE;
GO
EXEC sp_configure 'Ole Automation Procedures';
GO
|
如果设置失败 可尝试使用sys账号登录数据库再次执行
存储过程样例,使用需要修改请求IP和端口
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| USE [TEST_WMS] GO
SET ANSI_NULLS ON GO
SET QUOTED_IDENTIFIER ON GO
create Procedure [dbo].[SPCOM_WS_CONFIRM] @IN_ORDERNO varchar(20), @ResponseText varchar(8000) OUTPUT as declare @ServiceUrl as varchar(1000) set @ServiceUrl = 'http://221.4.136.225:18082/datahubWeb/WMSSOAPCLIENT/EXPRESS_CLIENT' DECLARE @data varchar(max); set @data='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <procWMSRequest xmlns="http://data.ws.datahub/"> <wmsSecurityInfo xmlns=""> <password>flux</password> <username>flux</username> </wmsSecurityInfo> <wmsParam xmlns=""> <customerid>EXPRESS_CLIENT</customerid> <messageid>EXPRESS_T</messageid> <param>'+@IN_ORDERNO+'</param> <stdno>EXPRESS_T</stdno> <warehouseid>WH01</warehouseid> </wmsParam> </procWMSRequest> </soapenv:Body> </soapenv:Envelope>' Declare @Object as Int
Exec sp_OACreate 'Msxml2.ServerXMLHTTP.3.0', @Object OUT; Exec sp_OAMethod @Object, 'open', NULL, 'POST',@ServiceUrl,'false' Exec sp_OAMethod @Object, 'setRequestHeader', NULL, 'Content-Type','text/xml;charset=UTF-8' Exec sp_OAMethod @Object, 'send', NULL, @data Exec sp_OAMethod @Object, 'responseText', @ResponseText EXEC sp_OAGetErrorInfo @Object Select @ResponseText Exec sp_OADestroy @Object
GO
|