Test a WCF service - c#

This question must be newbie and i know it but i haven't found the answer for some time now. I have implemented a WCF service which i want to test. So when i click open in browser it opened something like
So i created the configuration file and the code file and i have input it into my solution in the same folder where the web service lies. When i have put the c# code mentioned above in a button of a web form this
EDIT: This is the output.config that i have mentioned above (i hope that is the client's config)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Icheck_for_quantity" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:51182/check_for_quantity.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Icheck_for_quantity"
contract="Icheck_for_quantity" name="BasicHttpBinding_Icheck_for_quantity" />
</client>
</system.serviceModel>
</configuration>
If i run wcftestservice the following appears:

Related

How to include .config file inside C# .dll, that will use in vba project for ms access?

I am write an C# library that will use as reference for VBA
This library has service reference for some online product we using
and this service reference require an .config file to be in the same folder as the application/dll
when I use the service reference in .net application all work grate.
But when I use it in Ms access VBA I gets error about variables that are missing and I know they are in the config file.
I was trying few solutions i found but the problem is I cant change the variables in the reference cause we update it every few weeks.
so I have to include the config file with the .dll without change variables in the project.
Thanks,
config sample that the service reference use:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Isoapbinding" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.1.180/soap"
binding="basicHttpBinding" bindingConfiguration="Isoapbinding"
contract="time.Isoap" name="IsoapPort" />
</client>
</system.serviceModel>
</configuration>

Run WCF service with many connections

Is it possible to tun WCF service that could support several client types for example soap 1.1 and soap 1.2? Currently I have service with configuration below. I'm write that to support several connections I need to edit configuration file?
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" sendTimeout="00:05:00" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="IService1" name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>

Could not find default endpoint element that references contract... But application still works

I am currently working on a WPF Application, using a different project to call a WebService.
When I try to build i get this error:
Could not find default endpoint element that references contract
'VisitorRegistrationWebService.VisitorRegistrationWebServiceSoap' 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 contract could be found in the client
element.
The app.config from my webservice project is just the same as the one from my WPF project.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="VisitorRegistrationWebServiceSoap" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/webservices/VisitorRegistrationWebService.asmx"
binding="basicHttpBinding" bindingConfiguration="VisitorRegistrationWebServiceSoap"
contract="BasicVisitorRegistrationWebService.VisitorRegistrationWebServiceSoap"
name="VisitorRegistrationWebServiceSoap" />
</client>
</system.serviceModel>
</configuration>
The strange thing is that I can run the project and use the webservice to get data, but the error will not go away, no matter how many times I clean and rebuild my solution.
in error message, contract name is 'VisitorRegistrationWebService.VisitorRegistrationWebServiceSoap'
and in endPoint configuration, contract="BasicVisitorRegistrationWebService.VisitorRegistrationWebServiceSoap"

Class Project and WCF Could not find default endpoint element

I am adding a WCF client via “Add Service Reference” to the Class project with Visual Studio 2012. However I am getting the well known error:
Could not find default endpoint element that references contract ‘Service1.IService1′ 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 contract could be found in the client element.
The steps I followed was : (1) Create the Service1.cs and output.config via svcutil.exe, (2) Add service reference I am giving reference namespace as “MyFirstWcfWebServiceReference”. (3) add your existing Service1.cs file to the project. (4) in app.config Removed “MyFirstWcfWebServiceReference” and keep only IService1 in contract, (6) Build Project.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WCFServiceBinding" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/webiste/WebService.svc"
binding="basicHttpBinding" bindingConfiguration="WCFServiceBinding"
contract="IService1" name="WCFServiceBinding" />
</client>
</system.serviceModel>
</configuration>

wcf service wsHttpBinding over internet

Hello trying to get my binding to work over internet.
im using wsHttpBinding and trying to get it to work with soap.
i've tried NetTcpBinding and got my functions to show in the wcftestclient over the internet with my public ip and forwared my port to the right computer, but i could not call any functions failing with:
and i dont think soap can be used with NetTcpBinding so i've been trying to make this config work
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service
behaviorConfiguration="VenatoWCF.Behavior"
name="VenatoWCF.WCFService">
<endpoint
address=""
binding="wsHttpBinding"
contract="VenatoWCF.IService"
bindingConfiguration="Binding">
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8734/WCF/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="VenatoWCF.Behavior">
<serviceMetadata httpGetEnabled="true" />
<useRequestHeadersForMetadataAddress />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="Binding" >
<security mode="Message">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
</configuration>
this can be consumed by soap but this this config i cant get any respone with soap or wcftestclient.
soap: Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://(My External ip):8734/WCF/?wsdl' : failed to load external entity "http://(My External ip):8734/WCF/?wsdl"
thank you for answers
EDIT1 sorry wrong config file for thoose who where fast enough to see :/
EDIT2
found in my wsdl file that in the bottom i have <soap:address location="https://dendei:8734/WCF/" /> isent that one supposed to be the one soap connects too and need to be "https://(my external ip):8734/WCF/" ???
how can i change this one? in config file? or in my program?
EDIT3
stumbled on this site while searching UseRequestHeadersForMetadataAddressBehavior
and that solved it localy so i could have localhost in my baseaddress <add baseAddress="https://localhost:8734/WCF/"/>
and it worked with soap so i got back the address it tries to connect too
and worked over the net :)
but with UseRequestHeadersForMetadataAddressBehavior you have to use .NET 4.0
You error message says that you use this Url http://(My External ip):8734/WCF/?wsdl to connect to your service with WcfTestClient. But you defined a different Url in you config file. Have a look a your baseAddress. Try this Url http://(My External ip):8734/Venato/mex?wsdl
Alright got it to work if i switched to 4.0 and use UseRequestHeadersForMetadataAddressBehavior instead of trying to access the wsdl file and change the soap:address that points to the local address still dont know how to do that. :)
and the connection problem was in my computer firewall that blocked connection the router accepted the connection and my own computer blocked it xD
will edit my quest with the config that worked for me cheers!

Categories