更新:所以我想我需要以某种方式在方法参数中提交复杂类型 - 如何使用VBA执行此操作?
这是我第一次编写VBA编码,我将非常感谢能够解决问题的任何指示。基本上,我写了一个小肥皂服务,它工作正常 - 我用SoapUI测试 - 所以我猜其他应用程序应该能够使用它。
The WSDL the service generates is here。也许,它对VBScript SOAPClient的消费不太友好 - 那个方向上的任何点都会有很大的帮助。
我正在尝试将一些实际使用它的代码放在一起(下面的VBScript) - 我在google搜索时发现的一个例子上构建了它。它会生成以下错误:
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>
答案 0 :(得分: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
希望这对你有所帮助。