max
max

Reputation: 10454

adding a service reference to net.msmq wcf service

I'm trying to add a service reference to my wcf app in visual studio. I can do it for various bindings such as net.pipe and basichttp... but to net.msmq binding, I get error

Here is the relevant part of my web.config:

  <system.serviceModel>
    <bindings>
      <netMsmqBinding>
        <binding name="netMsmqBinding" exactlyOnce="false">
          <security mode="None"></security>
        </binding>
      </netMsmqBinding>
      <basicHttpBinding>
        <binding name="basicHttp" />
      </basicHttpBinding>
    </bindings>

    <behaviors>
      <endpointBehaviors>
        <behavior name="WCF_ServiceSample.WCF_ServiceBehavior" />
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="serviceBehavior">
          <serviceMetadata />
          <serviceDebug />
          <serviceDiscovery />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <services>
      <service behaviorConfiguration="serviceBehavior" name="WCF_ServiceSample.WCF_Service">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:4000/Services/" />
            <add baseAddress="net.msmq://localhost/Services/" />
          </baseAddresses>
        </host>

        <endpoint address="mex" behaviorConfiguration="WCF_ServiceSample.WCF_ServiceBehavior"
          binding="mexHttpBinding" bindingConfiguration="" name="mex_http"
          contract="IMetadataExchange" />

        <endpoint address="AdventureWorksServiceHttp" binding="basicHttpBinding" bindingConfiguration=""
          name="basicHttpEndpt" contract="WCF_ServiceSample.WCF_Service" />

        <endpoint address="AdventureWorksServiceNetMsmq"
          binding="netMsmqBinding" bindingConfiguration="netMsmqBinding"
          contract="WCF_ServiceSample.WCF_Service" />

      </service>
    </services>
  </system.serviceModel>

Here is the error I get when I run my service via the wcf client:

Error: Cannot obtain Metadata from http://localhost:9011/WCF_Service.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://localhost:9011/WCF_Service.svc Metadata contains a reference that cannot be resolved: 'http://localhost:9011/WCF_Service.svc'. The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.HTTP GET Error URI: http://localhost:9011/WCF_Service.svc There was an error downloading 'http://localhost:9011/WCF_Service.svc'. The request

failed with the error message:-- Server Error in '/' Application.

Could not find a base address that matches scheme net.msmq for the endpoint with binding NetMsmqBinding. Registered base address schemes are [http]. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

here is the error I get when I go to add service reference -> net.msmq://localhost/WCF_Service.svc then I press "Go"

The URI prefix is not recognized. The MetadataExchangeClient instance could not be initialized because no Binding is available for scheme 'net.msmq'. You can supply a Binding in the constructor, or specify a configurationName. Parameter name: scheme If the service is defined in the current solution, try building the solution and adding the service reference again.

Upvotes: 0

Views: 1020

Answers (1)

Bravo11
Bravo11

Reputation: 918

add mex bindings as that will allow you to add proxy reference, then you can use the net.msmq bindings to do the operation.

What is "mexHttpBinding"?

https://msdn.microsoft.com/en-us/library/aa967390(v=vs.110).aspx

Upvotes: 1

Related Questions