Friday, July 30, 2010

Problem creating a proxy class for a java web service using WseWsdl3.exe

I recently ran into a problem creating a proxy class for a Java web service using WseWsdl3.exe. The project would build just fine, however when an instance of the service class was created the following error was raised:

"Unable to generate temporary class (result=1) error CS0266: Cannot implicitly convert type object to Object[]"

The following article helped me realise that the WSDL generation tools will only be able to provide a best guess class definition and that you may in some cases need to tweak the generated code.

HOW TO: Change Types Used in Proxy Classes That Are Generated with Wsdl.exe

The following section shows the object definition from the wsdl:

<xs:complexType name="searchResult">
<xs:sequence>
<xs:element name="iteratorID" type="xs:decimal" minOccurs="0" />
<xs:element name="obj" type="ns1:anyTypeArray" nillable="true" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>

When a wsdl schema is published that contains nested nodes that have the maxOccurs attribute set to the "unbounded" value, the Wsdl.exe and WSEWsdl3.exe tools create multidimensional arrays in the generated code file. Therefore, the generated code contains incorrect types for the nested nodes. To solve the problem modify the generated code by removing the bracket ([]) array characters from the data type.

Only do this if you know that the service is going to return a single instance of an object.

In my case, I needed to change the following

private object[][] objField;

to

private object[] objField;

Monday, July 19, 2010

SharePoint site page title dissapears on page load

The page title on our SharePoint site disappeared after some code changes on the master page. Initially we thought SharePoint was doing something strange and found a work around that tried to resolve the problem by storing the site title in a global variable on page init and setting the document title once the page had fully loaded.
The title section in the header looked as follows:




Changing the title to the following format resolved the problem:



Strange but true.