1

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

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

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

我正在尝试将一些实际使用它的代码放在一起(下面的 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

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

我期望它应该产生这样的响应:

<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>
4

1 回答 1

0

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

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

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

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

希望这对您有所帮助。

于 2013-05-04T12:35:12.880 回答