首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >调用带有参数面错误代码的SOAP服务: 500内部服务器错误

调用带有参数面错误代码的SOAP服务: 500内部服务器错误
EN

Stack Overflow用户
提问于 2016-11-08 02:20:42
回答 1查看 712关注 0票数 1

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

我使用Windows 7来执行这个文件。

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-08 10:27:21

XML数据无效。开始的<soapenv:Envelope>标签缺少结束角括号,而标签<soapenv:Header>标签的尾斜杠在结束角括号之后。

改变这一点:

代码语言:javascript
复制
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>/" &_
             ...

这方面:

代码语言:javascript
复制
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

代码语言:javascript
复制
dt = mm & dd & hh & mm

可能应该是

代码语言:javascript
复制
dt = mm & dd & hh & mn

如果这不能解决问题,您可能需要检查webserver日志(错误500是服务器端的错误)和/或查阅API文档来验证您发送的请求是否具有正确的表单。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40477931

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档