Using Request Headers for Metadata Address

Source: Internet
Author: User

Problem description

I encountered an issue where adding a service reference failed after I deployed a normal service to the server locally.
The problem was resolved after replacing localhost with the base address in the configuration file with the server's IP address.
But I feel that this is not a problem because of careless writing the wrong address, the real reason may not be so simple.


You need to fill in the service's metadata address when adding a service reference, then click the Go button.
It could have been this way when it went wrong:

It could be like this:

Let's look at why they failed.
Open the corresponding address in the browser to see:

And also

Some of the links on the page are based on localhost, which is the base address set in the configuration file.
The preceding error hints are also mainly focused on the inability to get data on localhost, which is supposedly obtained from the server.
This is the reason for the problem-the metadata generated automatically by Http-get uses the base address of the service in the configuration.
So when I replace localhost with the base address in the configuration file with the server's IP address, the problem is resolved.

Solution Solutions

Although the method of using IP directly in the base address is valid, it is awkward, right.
Because we may access the service through many ways, such as IP, hostname, domain name, and the service may be deployed on a host in the intranet.
What should we do with so many complicated situations?
In fact WCF has been ready for us, just open the <useRequestHeadersForMetadataAddress> switch in the configuration, to:
Enables the retrieval of metadata address information from the request message headers.

1 <Behaviors>2   <servicebehaviors>3     <Behavior>4       <Servicemetadatahttpgetenabled= "true" />5       <userequestheadersformetadataaddress/>6     </Behavior>7   </servicebehaviors>8 </Behaviors>


Http:// (v=vs.110). aspx

Using Request Headers for Metadata Address

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.