2013-04-17 354 views
0

更新:所以我想我需要以某種方式在方法參數中提交一個複雜類型 - 如何使用VBA執行此操作?VBA MSSOAP.SoapClient30錯誤:爲SOAP請求提供的參數數量不正確HRESULT = 0x80070057

這是我第一次編碼VBA,我會很感激任何可能的指針,我如何解決這個問題。基本上,我已經寫了一點soap服務,它工作正常 - 我用SoapUI測試它 - 所以我猜其他應用程序應該能夠使用它。

The WSDL the service generates is here。也許,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> 

回答

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 

希望這有助於你。

相關問題