views:

219

answers:

2

I have extended a WCF service with new functionality in the form of a second service contract. The service.cs now implements both contracts. I have added another endpoint to expose the new contract operations. Here is my web.config relating to the service

<system.serviceModel>
    <bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding" />
  </basicHttpBinding>
        <webHttpBinding>
            <binding name="XmlHttpBinding"/>
        </webHttpBinding>
    </bindings>
    <services>
        <service name="MyNamespace.MyService" 
           behaviorConfiguration="MyServiceBehavior">
            <!-- Service Endpoints -->
            <endpoint address="xmlHttp1" 
              behaviorConfiguration="XmlHttpBehavior" 
              binding="webHttpBinding" 
              bindingConfiguration="XmlHttpBinding" 
              contract="MyNamespace.IContract1" />
    <endpoint address="xmlHttp2"
              binding="webHttpBinding"
              behaviorConfiguration="XmlHttpBehavior"
              bindingConfiguration="XmlHttpBinding"
              contract="MyNamespace.IContract2" />
    <endpoint address=""
              binding="basicHttpBinding"
              bindingConfiguration="BasicHttpBinding"
              contract="MyNamespace.IContract1" />
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="MyServiceBehavior">
                <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
                <serviceMetadata httpGetEnabled="true"/>
                <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
                <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
        </serviceBehaviors>
        <endpointBehaviors>
            <behavior name="XmlHttpBehavior">
                <webHttp/>
            </behavior>
        </endpointBehaviors>
    </behaviors>
</system.serviceModel>

From Javascript, calling 'http://server/wcfServiceApp/MyService.svc/xmlHttp1/Method1' still works fine.

Calling 'http://server/wcfServiceApp/MyService.svc/xmlHttp2/Method2' returns the 12031 error.

There must be something simple I'm not doing, any help is appreciated.

A: 

I've seen 12031 before associated with Viewstate errors (too much VS). How are you calling this service? Have you performed a simple HTTP trace with a tool like Fiddler to check what you're sending?

Thomas Beck
I'm calling the service from javascript using an xmlhttprequest object. The call is a "GET" to the service method. I've used the free version of httpwatch which showed me the ERROR_INTERNET_CONNECTION_RESET. It doesn't allow me to see any other details. Does my configuration look correct? I can successfully call the original methods from the first contract. It is only the new contract that I can't access
cyrix86
+1  A: 

I solved the problem. The business object (let's call it BusinessClass) that I was returning had the [DataContract()] attribute specified - which is fine.

However this class contained a custom collection (let's call it CustomCollectionClass) which ALSO had the [DataContract()] attribute specified.

Originally I was just going to return the CustomCollectionClass object but then decided to make the collection a member of a the BusinessClass - incase I decided to return multiple collections later. I forgot to remove the [DataContract()] attribute from the CustomCollectionClass. Once I removed that attribute - every thing was dandy.

I'm new to WCF so could one of you WCF experts follow up on this post and explain what was happening under the covers with having this attribute specified twice? I would love to understand this for future reference. Thank you.

cyrix86