Selling my book collection at Amazon…

I recently moved to a smaller place and can’t keep all my technical book collection.

I’m selling the books that I already read, no longer need or have duplicates. Some of them are for old .NET frameworks, but if you are maintaining legacy applications with these framework versions, the books from Microsoft Press can be helpful.

There are also books about SOA and SOAP, SQL Server specific books etc. The books are selling pretty fast.

You can access my seller’s collection at Amazon here.

All the prices are set for shipping within the USA only.

Happy coding!

Client proxy stub generation nightmare. SVCUtil generates colliding types. Beware of the porttype name and your data types…

This is one of the things that drives us insane from time to time. You may call this a bug, a lazy developer encapsulating bad code on a code generation tool, or just bad luck, but I quite some hours on this issue.

We have Java services that need to be consumed from C# client proxies. We do have a contract first approach and have the types defined on schema files and the service contracts are defined on their corresponding wsdl 1.2 files.

We validated the wsdl and xsd files with Altova XmlSpy and did the code generation with the svcutil tool several times, as well as the Visual Studio 2008 Add a Service Reference Tool.

The code generation  goes on fine, but the project that contains the proxy classes does not build. There are conflicting type names under the same namespace.

This does not happen with the Java client proxy generation tools, the Java code builds fine.

Here’s part of the problematic wsdl:

<?xml version=”1.0″ encoding=”utf-8″?>
<wsdl:definitions xmlns:tns=”http://service.some.com/Driver/” xmlns:soap12=”http://schemas.xmlsoap.org/wsdl/soap12/” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:comm=”schema” name=”Driver” targetNamespace=”http://service.some.com/Driver/” xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/”>
<wsdl:types>
<xsd:schema targetNamespace=”http://service.some.com/Driver/”>
<xsd:import schemaLocation=”Schema.xsd” namespace=”schema” />
<xsd:element name=”UpdateDriver”>
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”driverId” type=”xsd:int” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”driver” type=”comm:Driver” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”driverRelation” type=”xsd:int” />
<xsd:element minOccurs=”0″ maxOccurs=”unbounded” name=”claims” type=”comm:Claim” />
<xsd:element minOccurs=”0″ maxOccurs=”unbounded” name=”convictions” type=”comm:Conviction” />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name=”AddDriverConviction”>
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”driverId” type=”xsd:int” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”convictionDate” type=”xsd:date” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”convictionType” type=”xsd:int” />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name=”UpdateDriverConviction”>
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”driverId” type=”xsd:int” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”convictionId” type=”xsd:int” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”convictionDate” type=”xsd:date” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”convictionType” type=”xsd:int” />
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<wsdl:message name=”CreateDriverRequest”>
<wsdl:part name=”parameters” element=”tns:CreateDriver” />
</wsdl:message>
<wsdl:message name=”CreateDriverResponse”>
<wsdl:part name=”returnValue” element=”tns:CreateDriverResponse” />
</wsdl:message>
<wsdl:message name=”UpdateDriverRequest”>
<wsdl:part name=”parameters” element=”tns:UpdateDriver” />
</wsdl:message>
<wsdl:message name=”UpdateDriverResponse”>
<wsdl:part name=”returnValue” element=”tns:UpdateDriverResponse” />
</wsdl:message>

<wsdl:portType name=”Driver”>
<wsdl:operation name=”CreateDriver”>
<wsdl:input message=”tns:CreateDriverRequest” />
<wsdl:output message=”tns:CreateDriverResponse” />
</wsdl:operation>


</wsdl:portType>

<wsdl:binding name=”DriverSoapBinding” type=”tns:Driver“>
<soap12:binding transport=”http://schemas.xmlsoap.org/soap/http” />
<wsdl:operation name=”CreateDriver”>
<soap12:operation soapAction=”http://service.some.com/Driver/CreateDriver” />
<wsdl:input>
<soap12:body use=”literal” />
</wsdl:input>
<wsdl:output>
<soap12:body use=”literal” />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name=”UpdateDriver”>
<soap12:operation soapAction=”http://service.some.com/Driver/UpdateDriver” />
<wsdl:input>
<soap12:body use=”literal” />
</wsdl:input>
<wsdl:output>
<soap12:body use=”literal” />
</wsdl:output>
</wsdl:operation>

</wsdl:binding>
<wsdl:service name=”DriverService”>
<wsdl:port name=”DriverPort” binding=”tns:DriverSoapBinding”>
<soap12:address location=”http://www.example.org/” />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

and the schema file:

<?xml version=”1.0″ encoding=”utf-8″?>
<xsd:schema xmlns:this=”schema” targetNamespace=”schema” xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>

<xsd:complexType name=”Driver”>
<xsd:sequence>
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”person” type=”this:Person” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”driveInNASince” type=”xsd:date” />
<xsd:element name=”driverLicence” type=”xsd:string” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”provinceOfLicence” type=”xsd:int” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”graduateType” type=”xsd:int” />
<xsd:element name=”hasTrainingCertificate” type=”xsd:boolean” />
<xsd:element minOccurs=”1″ maxOccurs=”1″ name=”hasAutoInsuranceBefore” type=”xsd:boolean” />
<xsd:element name=”previousInsurer” type=”xsd:int” />
<xsd:element name=”previousPolicy” type=”xsd:string” />
</xsd:sequence>
</xsd:complexType>

</xsd:schema>

The generated code had a Driver Interface defined and a driver partial class defined.

After quite a few hours trying to figure out what was wrong (we changed the namespace names, the type names etc), a colleague pointed out the name of the port on the wsdl file.

Voilá!!!

On the service definition tag in the wsdl we put:

<wsdl:portType name=”DriverService“>
<wsdl:operation name=”CreateDriver”>
<wsdl:input message=”tns:CreateDriverRequest” />
<wsdl:output message=”tns:CreateDriverResponse” />
</wsdl:operation>

<wsdl:binding name=”DriverSoapBinding” type=”tns:DriverService“>


Now the interface is generated with the name DriverService and not Driver, so there is no collision with the data contract types, whew…

Happy development!!!