Microsoft KB Archive/840925

= You receive an &quot;unspecified client error&quot; error message when you run a Visual Basic for Applications program =

Article ID: 840925

Article Last Modified on 5/18/2007

-

APPLIES TO


 * Microsoft Visual Basic for Applications 6.0

-





SYMPTOMS
When you run a Microsoft Visual Basic for Applications (VBA) program that calls an XML Web service method, you may receive the following error message:

Run-time error '-2147221504 (80040000)':

Client:Unspecified client error.



CAUSE
An ArrayList object may contain elements of any data type. Therefore, when the Microsoft .NET Framework generates Web Services Description Language (WSDL) code that corresponds to an XML Web service method that returns an ArrayList object, the WSDL code does not specify the data type of the element that corresponds to the ArrayList object. When you try to call this XML Web service method, the Microsoft SOAP Toolkit cannot recognize the data type of the element that corresponds to the ArrayList object. Therefore, the SOAP Toolkit raises an error.



WORKAROUND
In the WSDL code that corresponds to the XML Web service method, specify the data type of the element that corresponds to the ArrayList object as anyType. To do this, follow these steps:  Locate the WSDL code that corresponds to your XML Web service, and then save this code as a WSDL contract file on your local computer.  In the WSDL contract file, locate the following WSDL code.        Replace the code that you located in step 2 with the following code.   <s:element minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot; name=&quot;anyType&quot; nillable=&quot;true&quot; type=&quot;s:anyType&quot;/> </s:sequence> </s:complexType> </li> Save and then close the WSDL contract file.</li> In the proxy class file for the XML Web service, replace the existing path of the WSDL contract information with the path of the WSDL contract file that you saved on your local computer in step 4.</li></ol>

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

Steps to reproduce the problem
<ol> Install the correct version of the Web Services Toolkit: <ul> If you are using Microsoft Office 2003, install the Microsoft Office 2003 Web Services Toolkit version 2.01.

To download the Office 2003 Web Services Toolkit 2.01, visit the following Microsoft Web site:

http://www.microsoft.com/downloads/details.aspx?FamilyID=fa36018a-e1cf-48a3-9b35-169d819ecf18

</li> If you are using Microsoft Office XP or Microsoft Office 2000, install the Microsoft Office XP Web Services Toolkit version 2.0.

To download the Office XP Web Services Toolkit 2.0, visit the following Microsoft Web site:

http://msdn2.microsoft.com/en-us/library/aa140324(office.10).aspx

</li></ul> </li> Create an XML Web service that contains an XML Web service method that returns an ArrayList object: <ol style="list-style-type: lower-alpha;"> Start Microsoft Visual Studio .NET.</li> Use Microsoft Visual Basic .NET to create a Microsoft ASP.NET Web Service project. Name the project MyService. By default, the Service1.asmx file is created.</li>  In the code view of the Service1.asmx file, locate the following code. End Class </li>  Add the following code before the code that you located in step c: <WebMethod> _ Public Function GetArrayList As ArrayList Dim MyArrayList As New ArrayList MyArrayList.Add(&quot;Blue&quot;) MyArrayList.Add(&quot;Green&quot;) MyArrayList.Add(&quot;Red&quot;) Return MyArrayList End Function </li> Build the solution to create the Service1 XML Web service.</li></ol> </li> Start Microsoft Excel.</li> On the Tools menu, point to Macro, and then click Visual Basic Editor. The VBA editor appears.</li> On the Tools menu, click Web Service References. <ul> If you are using Office 2003, the Microsoft Office 2003 Web Services Toolkit dialog box appears.</li> <li>If you are using Office XP or Office 2000, the Web Service References Tool 2.0 dialog box appears.</li></ul> </li> <li>Click Web Service URL.</li> <li>In the URL box, type the URL of the WSDL code that corresponds to the Service1 XML Web service. For example, if the URL of the Service1 XML Web service is http://MyServer/MyService/Service1.asmx, type http://MyServer/MyService/Service1.asmx?wsdl in the URL box.</li> <li>Click Search. The Service1 XML Web service appears in the Search Results box.</li> <li>In the Search Results box, click to select the Service1 check box, and then click Add. A class module that is named clsws_Service1 is added to your VBA project.</li> <li>In Project Explorer, right-click VBAProject (Book1), point to Insert, and then click UserForm. The UserForm1 user form is added to the VBA project.</li> <li>Add a command button to the UserForm1 user form. By default, the CommandButton1 command button is added to the UserForm1 user form.</li> <li>Double-click CommandButton1 to open the code view of the UserForm1 user form.</li> <li> Add the following code to the CommandButton1_Click event handler. Dim objArrayList As Variant Dim WebService As New clsws_Service1 Dim Item As Variant

objArrayList = WebService.wsm_GetArrayList

For Each Item In objArrayList MsgBox Item Next </li> <li>On the Run menu, click Run Sub/UserForm. The UserForm1 user form appears.</li> <li>Click CommandButton1.</li></ol>

The problem that is mentioned in the &quot;Symptoms&quot; section occurs.

<div class="references_section">