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();
}