Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I try to consume a SOAP api in C#. The code is compiled but when I run it, the following message appears:

<pre>System.InvalidOperationException
  HResult=0x80131509
  Message=Unable to generate a temporary class (result=1).
error CS0029: Cannot implicitly convert type 'string' to 'string[]'

  Source=System.Xml
  StackTrace:
   at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
   at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
   at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
   at System.Xml.Serialization.XmlSerializer.GetSerializersFromCache(XmlMapping[] mappings, Type type)
   at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
   at System.Web.Services.Protocols.SoapClientType..ctor(Type type)
   at System.Web.Services.Protocols.SoapHttpClientProtocol..ctor()
   at SOAPapi.Textkernel.SearchServiceService..ctor() in C:\Users\VanTol\Documents\Projects\CSharp\SOAPapi\SOAPapi\Web References\Textkernel\Reference.cs:line 45
   at SOAPapi.Program.Main(String[] args) in C:\Users\VanTol\Documents\Projects\CSharp\SOAPapi\SOAPapi\Program.cs:line 23


I checked all the parameter types and in the IDE they are correct.Does anybody have an idea what is going wrong?

The error occurs at codeline:
SearchServiceService client = new SearchServiceService();


What I have tried:

I created a C# console project and added the API as Web reference.
This is the wsdl: href="https://staging.textkernel.nl/SearchBox/soap/search?wsdl

This is the code:
static void Main(string[] args)
        {
            string ENVIRONMENT = "my_environment";
            string PASSWORD = "myPassword";
            string[] ACCESSROLES = new string[1];
            string LANGUAGE;
            accessOptions ACCESSOPTIONS = new accessOptions();
            searchRequest SEARCHREQUEST = new searchRequest();
            searchResult SEARCHRESULT = new searchResult();
            compositeMetadata METADATA = new compositeMetadata();
            userOptions USEROPTIONS = new userOptions();
            SearchServiceService client = new SearchServiceService();
            


            ACCESSROLES[0] = "all";
            LANGUAGE = "NL";
            
            METADATA = client.getMetadata(ENVIRONMENT, PASSWORD, ACCESSOPTIONS, LANGUAGE, USEROPTIONS, ACCESSROLES);

            Console.ReadKey();
        }
Posted
Updated 13-Mar-18 4:17am
Comments
vivvicks 13-Mar-18 7:46am    
one of the parameter from API method require string of array and your passing a string

1 solution

I found the answer. It's a Microsoft Visual Studio issue. The reference generated by Visual Studio contains an error.

See here for details: https://developer.salesforce.com/forums/?id=906F0000000AiPEIA0.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900