我开发了一个.vbs来调用SOAP服务,如下所示。在执行过程中,我得到错误代码500。如果你以前遇到过这种情况,请分享你的想法。
我使用Windows 7来执行这个文件。

Dim dt
mydt = Now()
mm = add0( Month(mydt))
dd = add0( Day(mydt))
hh = add0( Hour(mydt))
mn = add0( Minute(mydt))
ss = add0( second(mydt))
'WScript.Echo (Year(mydt)) & mm & dd & hh & mm & ss
'short-name: Max 8 char
dt = mm & dd & hh & mm
Function add0 (testIn)
Select Case Len(testIn) < 2
Case True
add0 = "0" & testIn
Case Else
add0 = testIn
End Select
End Function
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "C:\test"
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile In colFiles
strFileName = objFile.Name
If objFSO.GetExtensionName(strFileName) = "xml" Then
strUrl = "http://IP:Server/dummy"
strRequest = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/""" &_
" xmlns:v1=""http://crsoftwareinc.com/xml/ns/titanium/newbiz/newbusinessuploadreleaseservice/v1_0""" &_
" xmlns:v11=""http://www.crsoftwareinc.com/xml/ns/titanium/common/v1_0""" &_
" <soapenv:Header>/" &_
" <soapenv:Body>" &_
" <v1:new-business-upload-release-request>" &_
" <v1:new-business-upload-dto>" &_
" <v11:ID>ID="& dt &"</v11:ID>" &_
" <v11:file-name>"& objFile.Name &"</v11:file-name>" &_
" <v11:manual-upload>""false</v11:manual-upload>" &_
" <v11:auto-linking-enabled-flag>""true</v11:auto-linking-enabled-flag>" &_
" <v11:auto-merging-enabled-flag>""true</v11:auto-merging-enabled-flag>" &_
" <v11:strategy-option-choice>""USE_CREDITOR_DEFAULT_STRATEGY</v11:strategy-option-choice>" &_
" <v11:account-strategy-option-choice>""USE_CREDITOR_DEFAULT_STRATEGY</v11:account-strategy-option-choice>" &_
" <v11:auto-release>""true</v11:auto-release>" &_
" </v1:new-business-upload-dto>" &_
" <v1:web-service-request-version>""2</v1:web-service-request-version>" &_
" </v1:new-business-upload-release-request>" &_
"</soapenv:Body>" &_
"</soapenv:Envelope>"
End If
Next
Dim http
Set http = createObject("Msxml2.ServerXMLHTTP")
http.Open "POST", strUrl, False
http.setRequestHeader "Authorization", "Basic 123"
http.setRequestHeader "Content-Type", "text/xml"
http.send strRequest
If http.Status = 200 Then
WScript.Echo "RESPONSE : " & http.responseXML.xml
Else
WScript.Echo "ERRCODE : " & http.status发布于 2016-11-08 10:27:21
XML数据无效。开始的<soapenv:Envelope>标签缺少结束角括号,而标签<soapenv:Header>标签的尾斜杠在结束角括号之后。
改变这一点:
strRequest = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/""" &_
" xmlns:v1=""http://crsoftwareinc.com/xml/ns/titanium/newbiz/newbusinessuploadreleaseservice/v1_0""" &_
" xmlns:v11=""http://www.crsoftwareinc.com/xml/ns/titanium/common/v1_0""" &_
" <soapenv:Header>/" &_
...这方面:
strRequest = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/""" &_
" xmlns:v1=""http://crsoftwareinc.com/xml/ns/titanium/newbiz/newbusinessuploadreleaseservice/v1_0""" &_
" xmlns:v11=""http://www.crsoftwareinc.com/xml/ns/titanium/common/v1_0"">" &_
" <soapenv:Header/>" &_
...此外,在dt的构造中还使用了两次dt
dt = mm & dd & hh & mm可能应该是
dt = mm & dd & hh & mn如果这不能解决问题,您可能需要检查webserver日志(错误500是服务器端的错误)和/或查阅API文档来验证您发送的请求是否具有正确的表单。
https://stackoverflow.com/questions/40477931
复制相似问题