Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find endpoint element with name 'xxxxx' and contract 'yyy' in the ServiceModel client configuration section

I generated a proxy via this command -
svcutil.exe /language:cs /out:generatedProxy.cs /config:app.config https://service100.emedny.org:9047/MHService?wsdl

and then copied the elements from the resulting app.config into the app.config file of an existing project.

When I try to access the client in that config file via-

MHSClient serviceProxy = new MHSClient("MHSPort");

it should reference the second client below:

  <client>
  <endpoint address="https://webservices.hmsa.com/EDI27X/cstc/Hipaa27XService.svc"
            binding="customBinding" 
            bindingConfiguration="wsHttpEndpoint" 
            contract="HIPAA27XServiceContract" 
            name="wsHttpEndpoint" />
  <endpoint address="https://12.23.28.113:9047/MHService" 
            binding="customBinding"
            bindingConfiguration="MHService_MHSPort" 
            contract="MHS"
            name="MHSPort" />
</client>

but instead I get the error;
Could not find endpoint element with name 'MHSPort' and contract 'MHS' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.'

If I go to definition of MHSClient, it takes me to the proxy.cs file and this line;
public partial class MHSClient : System.ServiceModel.ClientBase, MHS


solved with the following-
endptAddress = new EndpointAddress(new Uri("uri"/xxxx"), EndpointIdentity.CreateDnsIdentity("xxxxxx"), addressHeaders);
MHSClient serviceProxy = new MHSClient(b, endptAddress);

like image 884
user2603361 Avatar asked Nov 12 '22 01:11

user2603361


1 Answers

solved with the following-
endptAddress = new EndpointAddress(new Uri("uri"/xxxx"), EndpointIdentity.CreateDnsIdentity("xxxxxx"), addressHeaders);

MHSClient serviceProxy = new MHSClient(b, endptAddress);

@Guanxi gave me the clue when asking about endpoint address from the config file.
Once I created the endpoint address then I could instantiate/create the service using the correct overload;
var b = new CustomBinding() as the first argument and for the second argument,
the correct endpoint address.

complicated - WS-Security - IBM Websphere server interop <-> wcf client
within the context of various .NET and Visual Studio implementations of web services...
oh my

like image 150
user2603361 Avatar answered Nov 14 '22 23:11

user2603361