2

I've added a proxy to a webservice to a VS2010/.NET 4solution. My machine is windows 7 OS. When constructing the client .NET throws this error:

Could not find endpoint element with name 'FulfilmentServicesSoap' and contract 'FulfimentServiceSoap.FulfilmentServicesSoap' 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.

I have found a simlar type question on SO here:

Could not find default endpoint element

However reading through this and attempting some of the answers has not worked for me. I have edited the app.config file a number of times including:

contract="IFulfimentServiceSoap" name="FulfilmentServicesSoap" />

and

contract="FulfimentServiceSoap.FulfilmentServicesSoap" name="FulfilmentServicesSoap" />

and

contract="MYFullNamespace.FulfimentServiceSoap.FulfilmentServicesSoap" name="FulfilmentServicesSoap" />

However in each case when I run my web service the event viewer show the contract 'FulfimentServiceSoap.FulfilmentServicesSoap' even when i have edited the config file. Is there something else I must do to pick up the changes in the app.config file or has anyone any other ideas?

EDIT - added binding info from app.config

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="FulfilmentServicesSoap" 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>
        <client>
            <endpoint address="http://localhost/WLR3.Web.services/FulfilmentServices.asmx"
                binding="basicHttpBinding" bindingConfiguration="FulfilmentServicesSoap"
               contract="FulfimentServiceSoap.FulfilmentServicesSoap"name="FulfilmentServicesSoap" />
        </client>
    </system.serviceModel>

EDIT - code where client is created.

FulfimentServiceSoap.FulfilmentServicesSoap fulfilmentServices = new FulfimentServiceSoap.FulfilmentServicesSoapClient("FulfilmentServicesSoap");
5
  • Without posting some more information (config), difficult to help.
    – Aliostad
    Apr 13, 2012 at 10:00
  • your app.config, web.config... need binding config.
    – Aliostad
    Apr 13, 2012 at 10:11
  • edited the question to include the binding config in app.config - I can hit the asmx page on localhost fine in IE Apr 13, 2012 at 10:15
  • OK, include the code how you create your client.
    – Aliostad
    Apr 13, 2012 at 10:17
  • Added code were client is created. Apr 13, 2012 at 10:28

2 Answers 2

2

If you deploy a project which doesn't use web.config or app.config such as Sharepoint Feature, your code block can't read web or app config and below exception may occur.

You may use the below code block before you call your web service in order to manipulate web or app config entries.

BasicHttpBinding httpBinding = new BasicHttpBinding();
httpBinding.Name = "DMS_WSSoap";
httpBinding.CloseTimeout = new TimeSpan(0, 1, 0);
httpBinding.OpenTimeout = new TimeSpan(0, 1, 0);
httpBinding.ReceiveTimeout = new TimeSpan(0, 10, 0);
httpBinding.SendTimeout = new TimeSpan(0, 1, 0);
httpBinding.AllowCookies = false;
httpBinding.BypassProxyOnLocal = false;
httpBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
httpBinding.MaxBufferSize = 65536;
httpBinding.MaxBufferPoolSize = 524288;
httpBinding.MaxReceivedMessageSize = 65536;
httpBinding.MessageEncoding = WSMessageEncoding.Text;
httpBinding.TextEncoding = Encoding.UTF8;
httpBinding.TransferMode = TransferMode.Buffered;
httpBinding.UseDefaultWebProxy = true;

httpBinding.ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas();
httpBinding.ReaderQuotas.MaxDepth = 32;
httpBinding.ReaderQuotas.MaxStringContentLength = 8192;
httpBinding.ReaderQuotas.MaxArrayLength = 16384;
httpBinding.ReaderQuotas.MaxBytesPerRead =  4096;
httpBinding.ReaderQuotas.MaxNameTableCharCount =16384;

httpBinding.Security.Mode = BasicHttpSecurityMode.None;
httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
httpBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
httpBinding.Security.Transport.Realm = "";
httpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;

//The url of web services.
EndpointAddress endpoint = new EndpointAddress("http://localhost/_layouts/DMS_WS/DMS_WS.asmx");

//one of the example web service which has been referenced in visual studio IDE.
LibraryWatcherWebService.DMS_WSSoapClient lservice = new LibraryWatcherWebService.DMS_WSSoapClient( httpBinding, endpoint);
1

Ok so figured this out for me anyway - will post here in case it helps anyone else. The DLL was created I copied to my Application/Libraries folder. (I didnt copy the app.config file that was created). In the code where I create the client I coded the binding and Endpoint address details and then passed them in to the SoapClient constructor. So my code for that looked as below:

BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress remoteAddress = new EndpointAddress("http://localhost/WLR3.Web.services/FulfilmentServices.asmx");
binding.Name = "FulfilmentServicesSoap";
binding.AllowCookies = false;

FulfimentServiceSoap.FulfilmentServicesSoap fulfilmentServices = new FulfimentServiceSoap.FulfilmentServicesSoapClient(binding, remoteAddress);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.