39

I have a successfully running WCF service that I can call using javascript. However I want to invoke it using the WCF test client and im having difficulty doing this. I am told that I need to make sure I have enabled meta data publishing at the specified address. After reading the documentation I just cant see what im meant to do this is my configuration:

    <system.serviceModel>
       <services>
           <service name="CommentSessionIDWCFService" 
                    behaviorConfiguration="CommentSessionIDBehavior">
              <endpoint 
                  address="" 
                  behaviorConfiguration="CountryProvinceBehavior"
                  binding="webHttpBinding" 
                  contract="ICommentSessionIDWCFService" />
           </service>
       </services>
       <behaviors>
          <serviceBehaviors>
             <behavior name="CommentSessionIDBehavior">
                <serviceMetadata httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="true"/>
             </behavior>
          </serviceBehaviors>
          <endpointBehaviors>
              <behavior name="CountryProvinceBehavior">
                  <webHttp/>
              </behavior>
          </endpointBehaviors>
       </behaviors>
    </system.serviceModel>

I've read other posts but I can't see what to populate and I just keep getting errors. Q's..

  1. Am I right in saying that I need to configure a complete new service in my config to show the metadata?

  2. What do I add to the configuration to make this meta data published so I can invoke with the client?

Florian Falk
  • 214
  • 4
  • 17
Exitos
  • 29,230
  • 38
  • 123
  • 178

4 Answers4

51

You need a metadata endpoint for your service, here`s an example.

<services>
    <service name="MyService" behaviorConfiguration="MEX">
    <endpoint
        address="http://localhost:8000/MEX"
        binding="mexHttpBinding"
        contract="IMetadataExchange"
    />
    </service>
</services>

<behaviors>
    <serviceBehaviors>
        <behavior name="MEX">
            <serviceMetadata/>
        </behavior>
    </serviceBehaviors>
</behaviors>
Chris J
  • 30,688
  • 6
  • 69
  • 111
Menahem
  • 3,974
  • 1
  • 28
  • 43
  • is this all I need to do? What does http://localhost:8000/MEX physically point to? – Exitos May 19 '11 at 11:33
  • 1
    it adds a endpoint on the server that listens on port 8000 for metadata requests based on the IMetadataExchange contract. it responds with the data needed to build a proxy to the service. VS uses this data when you do an 'add reference' operation. – Menahem May 19 '11 at 11:55
  • 16
    whomever down-voted this answer, please provide a reason for doing so. – Menahem Nov 06 '12 at 07:57
  • mine as well (+1) – Coding Duchess Oct 06 '16 at 18:40
  • @Menahem I have the same problem: where should I add the lines of codes you provided? In the app.config of my Proxy I have these: ' ' Should I edit the contract value? – franz1 Nov 18 '20 at 07:23
  • Hi @franz1 , the configuration in the answer is for the service side. The contract that you have '"ServiceReference1.IService1' is probably OK, and contains the operations you need for your app. – Menahem Nov 18 '20 at 09:13
0

I had a similar problem after changing the config file in the TestClient with right click and "edit with svceditor" to increase my maxbuffersize. If someone did that mistake as well, try rebuilding your project.

7gegenTheben
  • 81
  • 1
  • 10
0

Add

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

-1

Set httpGetEnabled to true and set the includeExceptionDetailInFaults to false:

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="false"/>
SharpC
  • 6,974
  • 4
  • 45
  • 40