This is a mirror of official site: http://jasper-net.blogspot.com/

Technical Note: Proxy Classes Different when using Svcutil.exe and VS Add Service Reference (doubleclick.com edition)

| Sunday, January 30, 2011
The WSDL url http://advertisersapi.doubleclick.net/v1.12/api/dfa-api/campaign?wsdl was used by a customer with the Svcutil.exe tool to generate a proxy class and associated message and data classes, and it worked fine. But when they tried to use the Add Service Reference... (often shortened to "ASR") wizard in Visual Studio, they had a problem: they could not import the fault contracts. In fact, even with Svcutil.exe, there was a warning generated due to the tool's inability to understand the WSDL:

Warning: Fault named ApiException in operation copyCampaigns cannot be imported.  Unsupported WSDL, the fault message part must reference an element. This fault message does not reference an element. If you have edit access to the WSDL docum ent, you can fix the problem by referencing a schema element using the 'element'  attribute.

In any case, the difference between ASR and Svcutil.exe is that one has the UseSerializerForFaults option easily available to you as a switch on the command line. Using this switch instructs Svcutil.exe to use the XmlSerializer to handle faults instead of the default, which is the DataContractSerializer. In this case, although Svcutil.exe has indicated that the WSDL for the fault is flawed, it continues to import the service operation. If you want to enable VS ASR to do the same thing:

  1. Click Show All Files in the Solution Explorer.
  2. Open the Reference.svcmap file in your service reference.
  3. Set the option <UseSerializerForFaults> to false in Reference.svcmap and save it. (NOTE: Take care NOT to update the service reference, as doing so resets the option to true.)
  4. Open the reference.cs and you should see the operations generated.

Read more:  Ralph Squillace -- Docs, Samples, Docs, Samples....

Posted via email from Jasper-net

0 comments: