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/BulkMutateJobService?wsdl
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()
-------------------
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:
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 <albert.ben...@gmail.com> 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...
i got help on this from Anash. he offered 2 resolutions:
1. the wsdl dummy one
2. and modifying the generated by wsdl.exe code
i choosed to use the second one, here it is:
-----quote from Anash's email-------
Search for all variables in your stub file, that looks like:
[System.Xml.Serialization.XmlArrayItemAttribute("operationResults",
typeof(OperationResult), IsNullable = false)]
public OperationResult[][] operationStreamResults {
...
}
and change them to
[System.Xml.Serialization.XmlArrayItemAttribute("operationResults",
typeof(OperationResult[]), IsNullable = false)]
public OperationResult[][] operationStreamResults {
...
}
Note the extra [] on XmlArrayItemAttribute. This change will allow
code to
compile and run fine, though I haven't verified if the server results
will
still be deserialized properly.
...
-----end quote----------------------------
i've encountered several more issues, most probably due to wsdl.exe
(bugs?). i've solved them - some with people's help and others alone.
could it be that wsdl.exe has swithes/options which are misused or not
used at all?
the other strange thing for me is why aren't there other .net users
asking those questions?
could it be that they are using .net3+ with the new wsdl tool (don't
recall it's name - wcf or something), and all those issues are solved
there? and if that's so, why is the adwords client library team
for .net not using .net3+? i am not pro-.net3+, just asking,
thanks in advance,
albert
I'm glad you were able to implement a solution to this problem. Anash
would be better able to answer these questions, but I believe the
AdWords API .NET client library is build on .NET 2.0 to allow for the
widest adoption, as many developers haven't yet switched to .NET 3.0
(yourself included it seems!). Out of curiosity, why aren't you able
to use the AdWords API .NET client library?
Best,
- Eric
1. the first one is that we've been using adwords api since v1. the
aw .net client library appeared several versions/years later.
2. i am not familiar with the aw api .net library, but i suppose it's
a good one. we are a 'do-it-ourselves' company. that is, the more we
can do alone, we do. we've fine tuned our aw api layer so that it
contains many features and intricate details which we won't be able to
get out of the box from any library. we are doing our best to
eventually get rid of the .net framework.
i really appreciate the help and high professional level of the
adwords api team, and especially the forum and email support. both
have saved us several times, thanks