DevX

i have been trying to do this for a while without success.-- i am switching from coding my endpoints in c# to using config files.-- i have the host set up fine but i cannot, for some reason get the clients to connect.-- i am using netTcpBinding and have tried to use the svcutil to create the proxy but with no luck.-- i am hosting my services in a windows service and the service/operation contracts are in their own class.

basically, i need to know how to interact in my code behind with the config file so i can instantiate the endpoint to make the call.

with the host it was easy servicehost sh = new servicehost(typeof(myServiceType));
wish the client had something like this.....


i would post more but don't know where to begin.

thanks for any help


Re: Windows Communication Foundation (Indigo) proxy for client creation

Brian McNamara - MSFT

Does your service publish metadata

For tcp, you probably want to add a ServiceMetadataBehavior, and add an IMetadataExchange endpoint with MetadataExchangeBindings.CreateMexTcpBinding(), and then hit that endpoint's address with svcutil. See

http://msdn2.microsoft.com/en-us/library/aa751951.aspx

for details.






Re: Windows Communication Foundation (Indigo) proxy for client creation

DevX

yes i have been trying to do that, but have a few questions.
can i not publish metadata on the same port that i am using for my servicehost
i tried to add the mexTcpBinding endpoint but it says that the port is already in use. -- do i have to reserve an extra port for each service

thanks for the quick response.




Re: Windows Communication Foundation (Indigo) proxy for client creation

Brian McNamara - MSFT

This should work; can you show the code (e.g. the 'new ServiceHost' and 'AddServiceEndpoint' calls) you are using




Re: Windows Communication Foundation (Indigo) proxy for client creation

sholman

The How Tos at http://msdn2.microsoft.com/en-us/library/ms731144.aspx and http://msdn2.microsoft.com/en-us/library/ms731862.aspx show an example of a client application that is configured in code and via the app.config file. It should be as simple as running svcutil to generate the proxy class and config file and then adding the proxy class to your VS client solution. When you want to instantiate the proxy in your code you should only need to do something similar to

myServiceTypeClient client = new myServiceTypeClient();

The framework will retrieve the binding and endpointaddress from the config file.

If this doesn't help I would post your app.config and the code you are currently using to create the client proxy.





Re: Windows Communication Foundation (Indigo) proxy for client creation

DevX

here is the service contract config before i run the svcutil
< xml version="1.0" encoding="utf-8" >
<configuration>
<system.serviceModel>
<bindings />
<client>
<endpoint address="net.tcp://localhost:8000/PtxInfoService" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IGetPtxInfo" contract="PatientList.IGetPtxInfo"
name="NetTcpBinding_IGetPtxInfo">

</endpoint>
</client>
</system.serviceModel>
</configuration>

... and then after i ran the utillity
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MetaData">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MetaData" name="PatientList.PtxInfoService">
<endpoint address="net.tcp://localhost:8000/PtxInfoService" binding="netTcpBinding"
bindingConfiguration="" contract="PatientList.IGetPtxInfo" />
<endpoint address="http://localhost:8001/PtxInfoService/mex"
binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://locahost:8001/PtxInfoService/mex" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>




Re: Windows Communication Foundation (Indigo) proxy for client creation

DevX

sorry, just realized that's probably not what you meant.--
k, after i expose the metadata...... what then




Re: Windows Communication Foundation (Indigo) proxy for client creation

Brian McNamara - MSFT

If this is how your service is configured:

...

<endpoint address="http://localhost:8001/PtxInfoService/mex"
binding="mexHttpBinding" contract="IMetadataExchange" />

Then you should try hitting http://localhost:8001/PtxInfoService/mex with svcutil. Does that work If not, what error does svcutil give you






Re: Windows Communication Foundation (Indigo) proxy for client creation

DevX

thanks again for the quick posts....
i ran the svcutil at that address and it gave me what i had before an output.config and a PtxInfoService.cs--
last time i added the .cs file to the project that is a client and added the output.config to the app.config in the same project.--
i don't know if this is correct. but after i did that and tried to run it gave me an error

InvalidOperationException----Could not find default endpoint element that references contract 'IGetPtxInfo' in the ServiceModel Client configuration section........




Re: Windows Communication Foundation (Indigo) proxy for client creation

Brian McNamara - MSFT

Can you share your whole (post svcutil) config file, and the client code where you are trying to new up a PtxInfoService client object




Re: Windows Communication Foundation (Indigo) proxy for client creation

DevX

##################
####config file######

< xml version="1.0" encoding="utf-8" >
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IGetPtxInfo" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8000/PtxInfoService" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IGetPtxInfo" contract="IGetPtxInfo"
name="NetTcpBinding_IGetPtxInfo">
</endpoint>
</client>
</system.serviceModel>
</configuration>
############################
## Client Call #################

GetPtxInfoClient proxy = new GetPtxInfoClient();
//this is the line that gets the error

######################################
##cs file that was generated for proxy by svcutil ##

using System.Data;



[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="IGetPtxInfo")]
public interface IGetPtxInfo
{

// CODEGEN: Parameter 'GetFilteredPtxInfoResult' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IGetPtxInfo/GetFilteredPtxInfo", ReplyAction="http://tempuri.org/IGetPtxInfo/GetFilteredPtxInfoResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
GetFilteredPtxInfoResponse GetFilteredPtxInfo(GetFilteredPtxInfoRequest request);

// CODEGEN: Parameter 'GetPtxInfoResult' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IGetPtxInfo/GetPtxInfo", ReplyAction="http://tempuri.org/IGetPtxInfo/GetPtxInfoResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
GetPtxInfoResponse GetPtxInfo(GetPtxInfoRequest request);

// CODEGEN: Parameter 'id' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IGetPtxInfo/UpdatePtxInfo", ReplyAction="http://tempuri.org/IGetPtxInfo/UpdatePtxInfoResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
UpdatePtxInfoResponse UpdatePtxInfo(UpdatePtxInfoRequest request);

// CODEGEN: Parameter 'id' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IGetPtxInfo/InsertPtxInfo", ReplyAction="http://tempuri.org/IGetPtxInfo/InsertPtxInfoResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
InsertPtxInfoResponse InsertPtxInfo(InsertPtxInfoRequest request);

// CODEGEN: Parameter 'UpdatePtxNotesResult' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IGetPtxInfo/UpdatePtxNotes", ReplyAction="http://tempuri.org/IGetPtxInfo/UpdatePtxNotesResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
UpdatePtxNotesResponse UpdatePtxNotes(UpdatePtxNotesRequest request);

// CODEGEN: Parameter 'id' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IGetPtxInfo/DeletePtxInfo", ReplyAction="http://tempuri.org/IGetPtxInfo/DeletePtxInfoResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
DeletePtxInfoResponse DeletePtxInfo(DeletePtxInfoRequest request);

// CODEGEN: Parameter 'GetPtxClassResult' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IGetPtxInfo/GetPtxClass", ReplyAction="http://tempuri.org/IGetPtxInfo/GetPtxClassResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
GetPtxClassResponse GetPtxClass(GetPtxClassRequest request);

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IGetPtxInfo/DeletePtxClass", ReplyAction="http://tempuri.org/IGetPtxInfo/DeletePtxClassResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
void DeletePtxClass(int id);

// CODEGEN: Parameter 'InsertPtxClassResult' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IGetPtxInfo/InsertPtxClass", ReplyAction="http://tempuri.org/IGetPtxInfo/InsertPtxClassResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
InsertPtxClassResponse InsertPtxClass(InsertPtxClassRequest request);

// CODEGEN: Parameter 'description' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IGetPtxInfo/UpdatePtxClass", ReplyAction="http://tempuri.org/IGetPtxInfo/UpdatePtxClassResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
UpdatePtxClassResponse UpdatePtxClass(UpdatePtxClassRequest request);
}

didn't post all of it as it is way to big --- posted this section from the top b/c it has a comment on each that i thought could be causing this.




Re: Windows Communication Foundation (Indigo) proxy for client creation

sholman

Are you running the client application and service on the same machine



Re: Windows Communication Foundation (Indigo) proxy for client creation

DevX

currently yes but i wanted to change to config files so i can modify later out side of code




Re: Windows Communication Foundation (Indigo) proxy for client creation

Brian McNamara - MSFT

So this

InvalidOperationException----Could not find default endpoint element that references contract 'IGetPtxInfo' in the ServiceModel Client configuration section........

makes it sound like maybe the client config file is not properly associated with the client application. Is the client config file you posted the application config file in the client application

Another way to test that, if you put
NetTcpBinding dummyBindingToValidateTheConfigFileIsThere =
new NetTcpBinding("NetTcpBinding_IGetPtxInfo");

in the client app, what happens




Re: Windows Communication Foundation (Indigo) proxy for client creation

DevX

ok i when i put the validation in there i get no elements matching the key 'NetTcpBinding_IGetPtxInfo' were found in the configuration element collection.-- so i guess that your assumption is correct.-- but how do i correct the association