我正在网上寻找一种使用ASP经典消费SOAP API的方法,我找到了类似这样的代码:
<%
Response.Write "<br>START<hr>"
Set oXmlHTTP = CreateObject("MSXML2.ServerXMLHTTP")
oXmlHTTP.Open "POST", "URL Web Service", False
SOAPRequest = _
"<?xml version=""1.0"" encoding=""utf-8""?>" &_
"<soap:Envelope xmlns:soap=""http://www.w3.org/2003/05/soap-envelope"" xmlns:aut=""URL.xsd"">"&_
"<soap:Header/>" &_
"<soap12:Body>" &_
"<aut:authorize>" &_
"<sessionToken>" &_ "SessionToken" &_ "</sessionToken>" &_
"<appId>appMobileDesa</appId>" &_
"<resource>/serviclub</resource>" &_
"<action>GET</action>" &_
"</aut:authorize>" &_
"</soap:Body>" &_
"</soap:Envelope>"
oXmlHTTP.setRequestHeader "Content-Type", "application/soap+xml;charset=UTF-8;action=""urn:Authorize""
oXmlHTTP.setRequestHeader "Content-Length", Len(SOAPRequest)
oXmlHTTP.setRequestHeader "Host", "URL:80"
oXmlHTTP.setRequestHeader "Connection", "Keep-Alive"
oXmlHTTP.send SOAPRequest
Response.Write oXmlHTTP.responseText
Response.Write "<br>END<hr>"
%>
我用文字替换了真实的URL和会话令牌。 基本上,它是一个调用API来请求授权的页面。 但是当我调用asp页面时,我一直收到错误500。 当我查看日志时,我发现了这个:
2018-04-27 18:19:17 10.5.42.121 GET /login/mobileYPF/autorizacion.asp |9|800a0409|Unterminated_string_constant 8080 - 10.5.42.121 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+6.1;+WOW64;+Trident/7.0;+SLCC2;+.NET+CLR+2.0.50727;+.NET+CLR+3.5.30729;+.NET+CLR+3.0.30729;+Media+Center+PC+6.0;+.NET4.0C;+.NET4.0E) 500 0 0 49
关于如何解决这个问题的任何想法?
答案 0 :(得分:1)
此行包含未终止的字符串常量:oXmlHTTP.setRequestHeader "Content-Type", "application/soap+xml;charset=UTF-8;action=""urn:Authorize""
如果你试图将urn:Authorize
包裹在引号中,它必须是这样的:
oXmlHTTP.setRequestHeader "Content-Type", "application/soap+xml;charset=UTF-8;action=""urn:Authorize"""
&lt; - 请注意结束"
(另外,"<sessionToken>" &_ "SessionToken" &_ "</sessionToken>" &_
是无效的语法。
应该是"<sessionToken>" & "SessionToken" & "</sessionToken>" &_
。如果你在同一条线上,则不需要_
。我意识到这可能是这篇文章的编辑部分。)