Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

InvalidOperationException when using soap client

I've added as wsdl file using the add servece reference dialog in vs2008.

MyService serviceproxy = new MyService();

When I instantiate the service proxy, I get an InvalidOperationException with the following text (translated from german):

Could not find default endpoint element to the contract "ServiceName.ServiceInterface" in the service model refers client configuration section. This may be because: The application configuration file was not found or not an endpoint in the client element item is found, which corresponded to this contract.

Where servicename is the name I give the service when I add it in vs2008 and ServiceInterface the interface which is automatically generated for it.

EDIT here is what's in my app.config:

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="MyServiceBinding" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
    </system.serviceModel>
like image 328
codymanix Avatar asked Nov 22 '25 05:11

codymanix


1 Answers

You need something like this in your config:

<client>
  <endpoint binding="basicHttpBinding" 
    bindingConfiguration="MyServiceBinding" contract="ServiceName.ServiceInterface"
    name="MyServiceEndpoint">
  </endpoint>
</client>

inside your tag

I just read your comment.

So Removed the address from the endpoint config.

You can choose to specify the endpoint completely in your code or just the address like this:

MyServiceClient proxy = new MyServiceClient();
proxy.Endpoint.Address = new EndpointAddress ("http://addressto your service"); //<-- address
like image 110
albertjan Avatar answered Nov 23 '25 19:11

albertjan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!