Hi I am new to Web Service concept, and also don't know much about WCF web service. I am trying to test WCF web service through soap UI. For that I have implemented Calculator Web service which have ADD,Substract,Multiply,Divide methods.
I have implemented this service on IIS on port 8001.
When I connect to Calculator WCF web service throug SOAPUI
I get the following exception
Sat Apr 04 04:21:22 IST 2015:ERROR:java.net.SocketException: Connection reset
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:149)
at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:110)
at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:264)
at org.apache.http.impl.conn.LoggingSessionInputBuffer.readLine(LoggingSessionInputBuffer.java:115)
at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:98)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:252)
at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:281)
at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:247)
at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:219)
at com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport$SoapUIHttpRequestExecutor.doReceiveResponse(HttpClientSupport.java:147)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:633)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:454)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport$Helper.execute(HttpClientSupport.java:233)
at com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport.execute(HttpClientSupport.java:323)
at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.submitRequest(HttpClientRequestTransport.java:290)
at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.sendRequest(HttpClientRequestTransport.java:220)
at com.eviware.soapui.impl.wsdl.WsdlSubmit.run(WsdlSubmit.java:119)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Below is the my Web.config file of Calculator WCF Web service.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="Calc.CalcServiceBehavior" name="Calc.CalcService">
<endpoint address="" binding="wsHttpBinding" contract="Calc.ICalcService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8001/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Calc.CalcServiceBehavior">
<serviceMetadata httpGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
My Web Service access URL is http://localhost:8001/Calc.svc
Below is my SOAPUI Request body to connect Calculator Web Service.
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
<soap:Header/>
<soap:Body>
<tem:Add>
<!--Optional:-->
<!--type: double-->
<tem:n1>1</tem:n1>
<!--Optional:-->
<!--type: double-->
<tem:n2>1</tem:n2>
</tem:Add>
</soap:Body>
</soap:Envelope>
It calls Add method of Calculator web service. Let me know if SOAP request is wrong.
Related
I've developed a wcf service with basichttpbinding. I've hosted the service on web server. There is a load balancer which exposes this service through https url. When i try to access the endpoint address exposed via load balancer it throws error in wcf test client - "The HTTP request was forbidden with client authentication scheme 'Anonymous'."
Below is the web.config configuration:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="testServiceBehavior">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceSecurityAudit auditLogLocation="Application" suppressAuditFailure="false"
serviceAuthorizationAuditLevel="SuccessOrFailure" messageAuthenticationAuditLevel="SuccessOrFailure" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="testServiceBehavior" name="TestService">
<endpoint address="" binding="basicHttpBinding"
contract="TestService.IService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
Make sure to enable anonymous authentication in IIS:
If this value is set to Disable, the client needs to provide Windows identity information when calling.
I have a WCF that is hosted in a windows service.
My service runs on port 16000 and I am using basicHttpBinding in my app.config file. The service runs fine and I am able to connect to it when using http.
I later added SSL security to my service, with the following in my windows service code:
myServiceHost = New ServiceHost(type)
myServiceHost.Credentials.ServiceCertificate.SetCertificate (StoreLocation.LocalMachine, StoreName.Root, X509FindType.FindByThumbprint, "thumbprint with spaces")
The program compiled and the windows service is running without any errors.
I then bound the SSL certificate to my 16000 port using netsh and instructions in the following link:
https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-configure-a-port-with-an-ssl-certificate.
However, when I am trying to add a reference to access it using https in the url, I am getting the exception: "Handshake failed due to unexpected packet format."
Here is my app.config file for reference:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"></serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="mexBehaviour" name="myService_ClassLib.myService">
<endpoint address="myService" binding="basicHttpBinding" bindingConfiguration=""
contract="myService_ClassLib.ImyService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:16000" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
Is there anything I am missing that's causing this error?
Thanks,
Sri
I am new to WCF and trying to understand Mex endpoints. I have created a testservice. Its working fine and I am able to view WSDL output from URL= "http://myweb.com:8000/testservice" as well using "URL" or "URL?wsdl".
However, I am getting 400 Bad request while browsing "URL/mex" in browser. I set httpGetEnabled="false" and then I am also able generate proxy class using svcutil as well.
Could you please advise why I am not able to veiw mex endpoint output in web browser. Below is the config file:
App.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="HelloTest.testservice" behaviorConfiguration="serviceBehaviour">
<endpoint binding="basicHttpBinding" contract="HelloTest.Itestservice" address="HelloTest">
</endpoint>
<endpoint binding="mexHttpBinding" contract="IMetadataExchange" address="mex">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://myweb.com:8000/testservice"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehaviour">
<serviceMetadata httpGetEnabled="true"></serviceMetadata>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I have started learning WCF and have created a few test http services successfully. Now, i was trying to create a self-hosted WCF service using net.pipe binding. Below is the configuration file for the service:-
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="MEX" name="InProcService.MyService">
<endpoint address="MyService"
binding="netNamedPipeBinding" bindingConfiguration="" contract="InProcService.IMyService" />
<endpoint address="Mex" binding="mexNamedPipeBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost/InProcService/" />
<add baseAddress="http://localhost:8001/InProcService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MEX" >
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Now in my host application, I am starting the service using:-
ServiceHost host = new ServiceHost(typeof(MyService));
host.Open();
Console.WriteLine("Service started");
host.Close();
The service starts correctly when this code is executed.
Now, when in my client application, I try to add the service reference to this running service, it is not able to find it. Is there something which I am not doing or doing incorrectly?
I would appreciate any help I can get on this.
Cheers,
Abhi.
The service is opened and closed after that. By the time you start the client the server is already closed. So Console.ReadKey() is required is requied before close.
I have a WCF service that receive query from a silverlight client and send the query to a Search API (Bing, or Google), process the search results to return those back to the silverlight client.
Everything works find in Visual Studio.
Once I publish the service in IIS, I can access the service endpoint and the silverlight client to talk to the service as well. However, the service does not send any query to the Search API. I opened Fiddler to monitor the traffic. There is no web request send to search API.
Is there any setting in IIS, or firewall, that I neglected?
The web.config is attached below:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="SiteRankerBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="SiteRankerBehavior" name="SiteDiscovery.SiteRanker">
<endpoint address="" binding="basicHttpBinding" contract="SiteDiscovery.ISiteRanker">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
Thanks
Sarah
Ok, I found the solution here that exactly solved my problem. Basically, I need to add the following to web.config and everything works.
<system.net>
<defaultProxy>
<proxy usessystemdefault="False" proxyaddress="http://your-proxy-name.domain.com:port-number-if-any" bypassonlocal="True" autoDetect="False" />
</defaultProxy>
</system.net>
Why it worked in Visual Studio is still a mystery to me though. Strickly speaking, it worked before in Visual Studio if the Fiddler is running at the same time.