VBA MSSOAP.SoapClient30 错误:为 SOAP 请求提供的参数数量不正确 HRESULT=0x80070057

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16062267/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 20:39:48  来源:igfitidea点击:

VBA MSSOAP.SoapClient30 error: Incorrect number of parameters supplied for SOAP request HRESULT=0x80070057

vbasoap

提问by abolotnov

update: so I've figured I need to somehow submit a complex type at method parameter - how do I do this with VBA?

更新:所以我想我需要以某种方式在方法参数处提交一个复杂类型 - 我如何使用 VBA 来做到这一点?

This is my first time coding VBA and I will appreciate any possible pointers at how I can fix the problem. Basically, I've written a little soap service and it works fine - I test it with SoapUI - so I guess other application should be able to consume it.

这是我第一次编写 VBA 代码,我将不胜感激有关如何解决问题的任何可能的指示。基本上,我编写了一个小肥皂服务并且它运行良好 - 我用 SoapUI 测试它 - 所以我猜其他应用程序应该能够使用它。

The WSDL the service generates is here. Perhaps, it is not too friendly for consuming by VBScript SOAPClient - any points in that direction will help a lot.

服务生成的 WSDL 在这里。也许,它对 VBScript SOAPClient 的使用不太友好 - 在这个方向上的任何点都会有很大帮助。

I'm trying to put a bit of code together that actually uses it (VBScript below) - I've built it on top of an example I found while googling. It generates the following error:

我正在尝试将一些实际使用它的代码放在一起(下面的 VBScript) - 我已经在谷歌搜索时发现的一个示例之上构建了它。它生成以下错误:

Incorrect number of parameters supplied for SOAP request HRESULT=0x80070057

Module Module1

    Dim WSDLFileName As String
    Dim base64attachment As String
    Dim attachment_filename As String
    Dim summary As String
    Dim SoapClient
    Dim res

    Sub Main()
        WSDLFileName = "http://localhost:7777/?wsdl"
        base64attachment = "UG9ydG1hbiBpcyBwb3J0Zm9saW8gbWFuYWdlbWVudCBzb2Z0d2FyZSB0byBoZWxwIFBNTyBrZWV"
        attachment_filename = "test_file.txt"
        summary = "test issue with summary"
        SoapClient = CreateObject("MSSOAP.SoapClient30")
        SoapClient.MSSoapInit(WSDLFileName)
        res = SoapClient.CreateJiraIssueWithBase64Attachment(summary, base64attachment, attachment_filename)
        Console.Out.WriteLine(res)
    End Sub

End Module

Any pointers will help, I'm lost here.

任何指针都会有所帮助,我在这里迷路了。

I'm expecting it should create a response like this:

我期待它应该创建这样的响应:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:open="open.JiraAdapter">
   <soapenv:Header/>
   <soapenv:Body>
      <open:CreateJiraIssueWithBase64Attachment>
         <open:summary>some summary</open:summary>
         <open:base64attachment>BASE64CODEDFILE</open:base64attachment>
         <open:attachment_filename>NAME of the file attached</open:attachment_filename>
      </open:CreateJiraIssueWithBase64Attachment>
   </soapenv:Body>
</soapenv:Envelope>

采纳答案by Mikhail Kislitsyn

Your service response contains complex type object.

您的服务响应包含复杂类型对象。

<xs:element name="CreateJiraIssueWithBase64AttachmentResult" type="s0:Status" minOccurs="0" nillable="true"/>

To be able to use complex types you need to use "MSSOAP.SoapSerializer30" to create request and "MSSOAP.SoapReader30" for reading response.

为了能够使用复杂类型,您需要使用“MSSOAP.SoapSerializer30”来创建请求和“MSSOAP.SoapReader30”来读取响应。

SOAP UI can helps you to see the correct request structure (tags, namespaces and actions). I think it something like that

SOAP UI 可以帮助您查看正确的请求结构(标签、名称空间和操作)。我认为它是这样的

Connector = CreateObject("MSSOAP.HttpConnector30") 
Connector.Property("EndPointURL") = "url"
Connector.Property("UseSSL") = True
Connector.Connect
Connector.Property("SoapAction") = "CreateJiraIssueWithBase64Attachment"
Connector.BeginMessage

Serializer = CreateObject("MSSOAP.SoapSerializer30")
Serializer.Init(Connector.InputStream)
Serializer.StartEnvelope
Serializer.StartBody
Serializer.StartElement("CreateJiraIssueWithBase64Attachment";"open.jiraAdapter.test")
Serializer.StartElement("summary";"open.jiraAdapter.test")
Serializer.WriteString("another test issue for JUR")
Serializer.EndElement
Serializer.StartElement("base64attachment";"open.jiraAdapter.test")
Serializer.WriteString("Y29kZTogaHR0cDovL3Bhc3RlYmluLmNvbS9EbUx3N0oycQ0KeG1sOiBodHRwOi8vcGFzdGViaW4uY29tLzE3Q2MxVjJM")
Serializer.EndElement 
Serializer.StartElement("attachment_filename";"open.jiraAdapter.test")
Serializer.WriteString("readme.txt")
Serializer.EndElement   
Serializer.EndElement   
Serializer.EndBody
Serializer.EndEnvelope    
Connector.EndMessage

Reader = CreateObject("MSSOAP.SoapReader30")
Reader.Load(Connector.OutputStream)  
/// Reader.Body.xml - response

Hope this help you.

希望这对你有帮助。