我有一个Web服务,用于在XML上执行xslt转换。我试图从SQL调用这个Web服务(不要问,它必须是这样的方式大声笑)。我在网上找到了这个SQL SP并试图用它来满足我的需求: http://www.vishalseth.com/post/2009/12/22/Call-a-webservice-from-TSQL-(Stored-Procedure)-using-MSXML.aspx
以下是asmx页面中对Web服务的描述:
POST /JobInvokerService.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://sqljobabca.org/TransformXML"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<TransformXML xmlns="http://sqljobabca.org/">
<inputDataXML>string</inputDataXML>
<inputTransformXML>string</inputTransformXML>
</TransformXML>
</soap:Body>
</soap:Envelope>
这是我用来调用SP的SQL: DECLARE @return_value int, @responseText varchar(8000)
EXEC @return_value = [dbo].[spHTTPRequest-Unedited]
@URI = N'http://localhost:3915/JobInvokerService.asmx',
@methodName = N'POST',
@requestBody = N'<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<TransformXML xmlns="http://sqljobabca.org">
<inputDataXML><NewProductListingRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><PublicComments/><PrivateComments/><BaseProduct></NewProductListingRequest></inputDataXML>
<inputTransformXML><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"><xsl:template match="/NewProductListingRequest"></xsl:template></xsl:stylesheet></inputTransformXML>
</TransformXML>
</soap:Body>
</soap:Envelope>',
@SoapAction = N'"http://sqljobabca.org/TransformXML"',
@UserName = NULL,
@Password = NULL,
@responseText = @responseText OUTPUT
SELECT @responseText as N'@responseText'
我修剪了XML参数以节省空间。
经过一些麻烦后,我可以让它实际上点击Web服务,但参数(inputDataXML和inputTransformXML)为空。
有什么建议吗?