views:

82

answers:

1

I am consuming a WCF Service from a webpart in Sharepoint 2007. But its giving me the following error:

There was no endpoint listening at http://locathost:2929/BusinessObjectService that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.

My Binding Details in the WCF web.config is:

<system.serviceModel>
    <diagnostics performanceCounters="All">
      <messageLogging logEntireMessage="true" logMessagesAtServiceLevel="false"
        maxMessagesToLog="4000" />
    </diagnostics>
    <services>
      <service behaviorConfiguration="MyService.IBusinessObjectServiceContractBehavior"
        name="MyService.BusinessObjectService">
        <endpoint address="http://localhost:2929/BusinessObjectService.svc"
          binding="wsHttpBinding" contract="MyService.IBusinessObjectServiceContract">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyService.IBusinessObjectServiceContractBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

My binding details in the Sharepoint site web.config is:

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IBusinessObjectServiceContract"
                    closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
                    sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false"
                    hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
                    maxReceivedMessageSize="65536" messageEncoding="Mtom" textEncoding="utf-8"
                    useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
              enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
                algorithmSuite="Default" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:2929/BusinessObjectService.svc"
          binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IBusinessObjectServiceContract"
          contract="BusinessObjectService.IBusinessObjectServiceContract"
          name="WSHttpBinding_IBusinessObjectServiceContract">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>

I am able to view the WCF (and its wsdl) in browser, using the URL given in the end point. So, I guess the URL is definately correct. Please help !!!

A: 

I've replicated your code and it runs correctly for me, but there are a couple of discrepencies.

Firstly, the server side configuration you've supplied is not complete. The endpoint mex fails because I don't have the IMetadataExchange contract. When you browse to the WSDL, this is presumably the endpoint you are viewing.

I'm just removing this endpoint altogether. Following from this, I'm specifying an address for the serviceMetadata element in the behavior like this:

<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:2929/BusinessObjectService.svc?wsdl" />

Not ideal but it works to let me discover the service. Then my generated client config file is the same as yours, except...

Secondly, I have messageEncoding="Text" instead of messageEncoding="Mtom"

Try changing messagingEncoding to Text. You haven't specified on server side that it should be Mtom so I don't understand why it has been generated on client side as Mtom.

Apart from these two issues my configuration is the same as yours, and it runs without a problem. I'm not sure that the second issue I've identified is a real issue at all (I can't see how the metadata exchange would give the wrong message encoding), but the first issue is stopping the service from running on my side.

Kirk Broadhurst
Have tried all the things you mentioned...but still not working. Is there anything else I am missing?
Bhaskar
Is the service being blocked by your windows firewall? Everything should be working - as I said, I tried this config and it worked for me. It's possible that it is a Windows or IIS configuration issue, i.e. something outside of .NET and WCF
Kirk Broadhurst
will check and will get back.....
Bhaskar