Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
595 views
in Technique[技术] by (71.8m points)

c# - Error: Cannot obtain Metadata from WCF service

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...