Issues with the client generated by WCF/

Source: Internet
Author: User

The WCF server I createdProgramThe customer cannot be generated all the time with the svcutil command

Error message:

Metadata contains reference that cannot be parsed: "net. TCP: // 127.0.0.1: 6987/do"

Net. TCP: // 127.0.0.1: 6987/do

Solution Law 1:

Add the following in the program:Code

If (host. description. behaviors. Find <system. servicemodel. description. servicemetadatabehavior> () = NULL)
{
Bindingelement elemnt = new tcptransportbindingelement ();
Custombinding bind = new custombinding (elemnt );
Host. description. behaviors. Add (new system. servicemodel. description. servicemetadatabehavior ());
Host. addserviceendpoint (typeof (system. servicemodel. description. imetadataexchange), bind, "mex ");
}

Solution 2

How to change the server configuration file is as follows:

<? XML version = "1.0" encoding = "UTF-8"?>
<Configuration>
<System. servicemodel>
<Services>

<Service name = "leleapplication1.do" behaviorconfiguration = "idobehavior">
<Endpoint address = "duplex" binding = "nettcpbinding" Contract = "leleapplication1.ido">

<Identity>
<DNS value = "localhost"/>
</Identity>

</Endpoint>

<! -- Metadata endpoints -->
<! -- The metadata exchange endpoint is used by the Service to describe itself to the client. -->
<! -- This endpoint does not use secure binding. You should ensure security or delete it before deployment. -->
<Endpoint address = "mex" binding = "nettcpbinding" Contract = "imetadataexchange"/> // to use svcutil to generate client files, you must include this code

</Service>
</Services>

// To generate a client file using svcutil, the following code must be included:

<Behaviors>
<Servicebehaviors>
<Behavior name = "idobehavior">
<! -- To avoid metadata leakage,
Set the following value to false before deployment and delete the above metadata endpoint -->

<! -- Service metadata publishing and related information
Attribute description:
The value of the httpgetenabled-bool type indicates whether to allow the http get method to obtain the WSDL metadata of sevice.
Httpgeturl-If httpgetenabled is true, this attribute indicates the URL used to publish the Service's WSDL,
If this attribute is not set, add? WSDL -->
<Servicemetadata httpgetenabled = "true" httpgeturl = "http: // 127.0.0.1: 64987/do"/>
<! -- Receives fault exception details for debugging,
Set the value to true. Before deployment
Set to false to avoid leakage of exception information -->
<Servicedebug includeexceptiondetailinfaults = "false"/>
</Behavior>
</Servicebehaviors>
</Behaviors>

</System. servicemodel>
</Configuration>

 

the address written after svcutil is: Address in httpgeturl set in servicemetadata configuration section

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: info-contact@alibabacloud.com 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.