Consuming service reference in web api - wcf

1)I am creating a ASP.NET Web Application-> Empty (Web Api selected) project in VS2013 and adding service reference (wsdl)
public class BJKController : ApiController
{
[HttpGet]
public byte[] GetArchive(string workOrderNo)
{
BjkClient client =new BjkClient();
return client.GetInvoice(workorderNo);//I'm getting error this line
}
}
web.config:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ICompany" maxReceivedMessageSize="64000000">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://service.karakartal.com.tr/Company.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICompany"
contract="ServiceReference1.ICompany" name="WSHttpBinding_ICompany" />
</client>
</system.serviceModel>
I'm was debugging and got error in webapi project : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond X.X.XXX.XXX:443
But I am trying a windows project (add service refence too)
everything same (web config and using). It is working fine.

When I moved to IIS it worked fine.

Related

WCF Endpoint does not use provided Https binding

I'm calling an external WCF service and am getting the following error message. "The provided URI scheme 'http' is invalid; expected 'https'. Parameter name: via"
here are the config sections pertaining to the service:
<client>
<endpoint address="https://www.odfl.com:443/wsRate_v4/RateService" binding="basicHttpBinding" bindingConfiguration="RatePortBinding" contract="OdflRateService.RateDelegate" name="RatePort" />
</client>
and the binding Section:
<bindings>
<basicHttpBinding>
<binding name="RatePortBinding">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
The assembly is calling the service is loaded into the app through reflection and the configuration values are in the main app web config. I don't know if this makes any difference but thought i should mention it.
Thanks!

Error: The HTTP request is unauthorized with client authentication scheme 'Negotiate'

I keep getting the above error when my client program tries to call my WCF service method. It is passing credentials via ClientCredential.UserName.
I am not able to figure out what's happening here and all the posts related to this kind of issue are not solving this problem.
Mine is a shared hosting Environment on Godaddy server where my WCF service is hosted.
Configuration is as follows:
<endpoint
name="wsBinding"
address=""
binding="wsHttpBinding"
contract="ServiceLib.IBooking"
bindingConfiguration="myWSSettings"/>
<bindings>
<wsHttpBinding>
<binding name="myWSSettings">
<security mode="Transport">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
Would really appreciate any help.
Thanks
Sandeep

WCF UserName clientCredentialType

I have a WCF service with following configuration:
<service behaviorConfiguration="MyServiceBehavior" name="Service1">
<endpoint address=""
binding="wsHttpBinding" bindingConfiguration="MembershipBinding"
name="ASPmemberUserName" contract="TestWcfService.IService1" />
</service>
.
.
.
.
.
<wsHttpBinding>
<binding name="MembershipBinding">
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
I want to pass the username to the service proxy on client and retrieve it on the server side. I use bellow code to pass the user name to the proxy class:
Service1Client sc = new Service1Client();
sc.ClientCredentials.UserName.UserName = HttpContext.Current.User.Identity.Name;
When I try to retrieve the username on the server, the ServiceSecurityContext.Current returns null. Any ideas why it acts like this?
The problem was caused by certificate settings. Below link helped solve the issue:
A simple WCF service with username password authentication: the things they don’t tell you

WP7 + WCF Service: There was no endpoint listening at (URL) that could accept the message

I'm trying to develop a Windows Phone application that uses a WCF Service. I'm doing it as decribed here:
http://www.c-sharpcorner.com/UploadFile/raj1979/5280/
(of course I use my own tables from the DB). The problem is:
I'm debugging the Class Library project containing the WCF service (to see if some of its methods are invoked properly)
after the method returns an entity I see the error: There was no endpoint listening at http://localhost:1708/Service1.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. The InnerException is The remote server returned an error: NotFound.
the ServiceReferences.ClientConfig in the Windows Phone application:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1708/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
I don't know how to solve it. Any ideas ? I tried many answers from that site but none worked
What about Silverlight-enabled WCF service on the server side? It it based on CustomBinding instead of basicHttpBinding.
You must change in ServiceReferences.ClientConfig in your Windows Phone Emulator endpoint address from localhost to
yourComputerName. Thats all:) It works

WCF Error: Stream Security is required at http://www.w3.org/2005/08/addressing/anonymous, but no security context was negotiated

We have a windows service that we are trying to use as WCF host for a WPF application. It works fine in development but when we have tried to move to our production environment we have had nothing but problems. From reading posts from others, we figured out how to turn on WCF logging and this was a big help. It turned out that our security bindings on the service and the client did not match. We set them both to use windows security but still no luck now we are trying to set the security mode to 'None' but it still is not working. Here is the bindings section of our service config file:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="netTcp">
<security mode='None'>
</security>
</binding>
</netTcpBinding >
</bindings>
<services>
<service name="CompanyService">
<endpoint
address= "our.url.com/CompanyService"
binding="netTcpBinding"
contract="CompanyServices.ICompanyService" />
</service>
</services>
</system.serviceModel>
Here is the serviceModel section of our client app config:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_Config" >
<security mode="None">
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="our.url.com/CompanyService" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Config" contract="CompanyServiceProxy.ICompanyService" name="NetTcpBinding_ICompanyService" />
</client>
</system.serviceModel>
If I need to supply additional infor please tell me what I need to supply.
Thanks
Standard net.tcp binding uses Windows credentials by default, and those really require client and service to be in the same Windows domain. Is this the case here??
OK, sorry, you mentioned security=None (your listings weren't properly formatted so I only saw a fraction of the actual config).
I guess your problem really lies in the addresses used:
address= "our.url.com/CompanyService"
When using net.tcp binding, you have to specify that before the address, so change this on both the client and the server to:
address= "net.tcp://our.url.com/CompanyService"
Also, what I don't quite understand is your title: it mentions "streaming" - have you specified streaming mode anywhere? In your config or your service contracts?
Marc