Hi Albert,

I am not an expert on the topic, but from what I know the .NET 2.0
WSDL generator (wsdl.exe) is to blame in this case.  When it is
creating classes from the WSDL, if it finds an array of arrays it will
collapse the entire structure into one flat array.  The error is
caused when the array of arrays returned by the service is trying to
be unmarshaled into the generated object.  As far as I know there is
no way to disable this behavior in the WSDL generator.

In this case the WSDL generator finds the BulkMutateResult field
"operationStreamResults", which is an array of OperationStreamResult:

  
http://code.google.com/apis/adwords/v2009/docs/reference/BulkMutateJobService.BulkMutateResult.html

In turn each OperationStreamResult has only one field
"operationResults", which is an array of OperationResult:

  
http://code.google.com/apis/adwords/v2009/docs/reference/BulkMutateJobService.OperationStreamResult.html

What is happening is that the BulkMutateResult field
"operationStreamResults" is converted by the WSDL generator into an
array of OperationResult, totally skipping over the
OperationStreamResult layer.  This structure doesn't match that
returned by the service, which is causing the casting error.

The current solution that the AdWords API .NET Client Library uses,
although not ideal, is to manually alter the WSDL before it's
processed, injecting an extra field into OperationStreamResult so that
the type will not be stripped out by the WSDL generator.  The script
that does that is here:

  
http://code.google.com/p/google-api-adwords-dotnet/source/browse/trunk/tools/ProcessWsdl.cs

Because of this strange behavior of the .NET WSDL generator and others
we recommend that .NET developers use the AdWords API .NET client
library when possible.

Best,
- Eric Koleda, AdWords API Team

On Jan 2, 4:17 pm, Albert <[email protected]> wrote:
> hi,
>
> i am using .net 2/c# with adwords api2009 (without the .net client
> library).
>
> i am trying to instantiate the BulkMutateJobService:
>
> BulkMutateJobService service =
>                 new BulkMutateJobService();
>
> and i get the following error (see at the end ):...
>
> i have already fixed 1 issue with the SoapHeader class by renaming it
> (thanks to this forum), but i am clue-less with this one,
>
> i am generating the stubs using:
> wsdl.exe /l:cs /o:C:\AdWordsService2.cs /sharetypes /
> n:Service.ref_AdWords2  
> https://adwords.google.com/api/adwords/job/v200909/BulkMutateJobServi...
>
> any help appreciated,
>
> thanks in advance,
> albert
>
> ps. using the .net client library is not an option
>
> --------------------
>
> System.InvalidOperationException was unhandled
>   Message="Unable to generate a temporary class (result=1).\r\nerror
> CS0030: Cannot convert type 'Service.ref_AdWords2.OperationResult[]'
> to 'Service.ref_AdWords2.OperationResult'\r\nerror CS0029: Cannot
> implicitly convert type 'Service.ref_AdWords2.OperationResult' to
> 'Service.ref_AdWords2.OperationResult[]'\r\n"
>   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 Service.ref_AdWords2.BulkMutateJobService..ctor() in C:
> \Inetpub\wwwroot\webServices\Service\Web References
> \ref_AdWords2\AdWordsService2.cs:line 6502
>        at Service.API.AdWords2.BulkService.Test_getbulks() in C:
> \Inetpub\wwwroot\webServices\Service\API\AdWords2\BulkService.cs:line
> 12
>        at ConsoleDebugger.Test12.Test_aw_getbulks() in C:\Inetpub
> \wwwroot\webServices\ConsoleDebugger\Test12_6aw2.cs:line 124
>        at ConsoleDebugger.Program.RunTest44() in C:\Inetpub\wwwroot
> \webServices\ConsoleDebugger\Program.cs:line 21
>        at ConsoleDebugger.Program.Main(String[] args) in C:\Inetpub
> \wwwroot\webServices\ConsoleDebugger\Program.cs:line 14
>        at System.AppDomain._nExecuteAssembly(Assembly assembly, String
> [] args)
>        at System.AppDomain.ExecuteAssembly(String assemblyFile,
> Evidence assemblySecurity, String[] args)
>        at
> Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
>        at System.Threading.ThreadHelper.ThreadStart_Context(Object
> state)
>        at System.Threading.ExecutionContext.Run(ExecutionContext
> executionContext, ContextCallback callback, Object state)
>        at System.Threading.ThreadHelper.ThreadStart()
> -------------------

--

You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/adwords-api?hl=en.


Reply via email to