i'm experiencing problems on my WP8.0 app, I want to access a HTTPS WCF service from it with BASIC authentication.
Everything is already working on a C# console app which uses .NET framework 4.5
WORKING CONSOLE APP CODE :
App.config :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpsBinding>
<binding name="WS_CubicusMobileSOAPBinding">
<security mode="Transport">
<transport clientCredentialType="Basic" proxyCredentialType="Basic" realm="xxxxxx.xx.xx" />
</security>
</binding>
</basicHttpsBinding >
</bindings>
<client>
<endpoint address="https://xxx.xxx.xx/xxx/awws/xxxxx.awws"
binding="basicHttpsBinding" bindingConfiguration="WS_CubicusMobileSOAPBinding"
contract="ServiceReference1.WS_CubicusMobileSOAPPortType"
name="WS_CubicusMobileSOAPPort" />
</client>
</system.serviceModel>
</configuration>
And this C# code :
ServiceReference1.WS_CubicusMobileSOAPPortTypeClient proxy = new WS_CubicusMobileSOAPPortTypeClient();
proxy.ClientCredentials.UserName.UserName = "xxxxxx";
proxy.ClientCredentials.UserName.Password = "xxxxxx";
var e = proxy2.ConnexionTestWP(anObject);
NOT WORKING WP8.0 CODE :
ServiceReferences.ClientConfig :
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WS_CubicusMobileSOAPBinding" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://xxxxx.xxxxx.xxx/xxxxx/awws/xxxxx.awws"
binding="basicHttpBinding" bindingConfiguration="WS_CubicusMobileSOAPBinding"
contract="ServiceReference1.WS_CubicusMobileSOAPPortType" name="WS_CubicusMobileSOAPPort" />
</client>
</system.serviceModel>
</configuration>
The C# code is exactly the same than the console app one (except it's Async).
I receive a CommunicationException saying "Additional information: The remote server returned an error: NotFound."
The only thing Fiddler sees :
http://i.stack.imgur.com/VzYhf.png
I heard that Silverlight clients needs crossdomain.xml on client side to work, so I included this file on the server root. Still not working...
I feel like I tried every binding (like custombinding), every c# code (like adding the Authorization header inside the WCF request manually), every kind of configuration etc... Nothing is working.
Please help me out i'm desperate !
You're using basicHttpBinding in Windows Phone but basicHttpsBinding in console app. Have you turned off http on the server?
Related
I am trying to configure a WCF service through the app.config file so it defaults to getting the TLS settings from the OS (we want the service to use TLS 1.2 as default, actually), and I am trying to follow the Transport Layer Security (TLS) best practices with the .NET Framework article.
But when I try to add the sslProtocols parameter to the transport attribute, it seems like it does not exist.
Do we lack some Assembly or other dependencies? Did it change from NET Framework 4.8?
Our config file is as follows:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="siiBinding">
<security mode="Transport"/>
</binding>
<binding name="siiBinding1">
<security mode="Transport"/>
</binding>
<binding name="siiBinding2">
<security mode="Transport"/>
</binding>
<binding name="siiBinding3"/>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://www1.agenciatributaria.gob.es/wlpl/SSII-FACT/ws/fe/SiiFactFEV1SOAP" binding="basicHttpBinding" bindingConfiguration="siiBinding" contract="SuministroFactEmitidasReference.siiSOAP" name="SuministroFactEmitidas"/>
<endpoint address="https://www10.agenciatributaria.gob.es/wlpl/SSII-FACT/ws/fe/SiiFactFEV1SOAP" binding="basicHttpBinding" bindingConfiguration="siiBinding1" contract="SuministroFactEmitidasReference.siiSOAP" name="SuministroFactEmitidasSello"/>
<endpoint address="https://www7.aeat.es/wlpl/SSII-FACT/ws/fe/SiiFactFEV1SOAP" binding="basicHttpBinding" bindingConfiguration="siiBinding2" contract="SuministroFactEmitidasReference.siiSOAP" name="SuministroFactEmitidasPruebas"/>
</client>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
Make sure your system.web is similar to the following:
<system.web>
<compilation targetFramework="4.8"></compilation>
<httpRuntime targetFramework="4.8" />
</system.web>
and transfer mode
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
Try adding in global.asax.cs using System.Net.
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
For details you can check the documentation.
How to: Configure an IIS-hosted WCF service with SSL
TcpTransportSecurity.SslProtocols Property
Description
I have a WCF web service and a WCF client, running on the same machine. I'm using windows authentication. I'm trying to connect from the client, as a chosen domain user:
var client = new MyService.ServiceClient();
client.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("USER", "PASSWORD", "DOMAIN");
client.ReceiveData("hello");
Unfortunately the last line results in the error:
The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'
How can i resolve this?
Note:
This works on a different machine in a different domain. So it's probably a setting on my machine.
This does not happen for local users:
client.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("LOCALUSER", "PASSWORD", "");
I get the same error when i enter the wrong password for a local user.
This also does not happen when i am already logged in as the domain user, and don't specify credentials:
var client = new MyService.ServiceClient();
client.ReceiveData("hello");
When i remove NTLM from [Authetication > Windows Authetication >
Providers...], then i instead get the puzzling error:
The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate'.
client App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
<binding name="BasicHttpsBinding_IService">
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/MyService/Service.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
contract="MyService.IService" name="BasicHttpBinding_IService" />
</client>
</system.serviceModel>
</configuration>
I know this topic has been discused multiple times already, but unfortunately non of the provided solutions workd for me.
I try to transfer large files (up to 1.5 GB) from a client console application to a WCF service.
But I always get an HTTP error The remote server returned an unexpected response: (413) Request Entity Too Large. while transmitting the file content.
All information I found in the internet where about adding maxContentLength and similar configuration to web.config file.
But I assume I entered them at a wrong part from the web.config or so.
Edit 26.02.2020 18:35 (updated due to hints and new tests)
Based on the tipps from above I added some entries to config files and did some more tests.
In the mean time I found out a few things:
The number in web.config define the size in bit not in bytes as I read on severall pages
The number must be a valid int32 - so the maximum value is 2147483647
2147483647 bit are around 256 MByte - so it's understandable, that my testfile with around 400MB caused a problem
Overall, if it's not possible to transfer the large files - at least 20-30 MB should be possible.
For larger files I will find an other solution then.
To do easier tests I just created a new empty WCF service and a console application to test it.
You can find the complete sourcecode on Google Drive.
I included a 22MB test image as well, which doesn't work to transfer.
Different to my first problem, I now get a 404 error instead of a 413.
So somehow the IIS returns a 404 when the request is not matchable to a service instead of the previous 413.
A pretty strange behaviour for me.
The web.config and the app.config looks still the same as before (beside there is no entity framework stuff in).
Server web.config
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="mybinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None"/>
</binding>
</basicHttpBinding>
</bindings>
<protocolMapping>
<add binding="basicHttpBinding" scheme="http" bindingConfiguration="mybinding" />
</protocolMapping>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
Client app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="mybinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:53042/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="mybinding" contract="ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
As I'm not a pro regarding web.config configuration, I assume, I just added the configuration in a wrong section of the XML.
Can anybody provide me some help, how my web.config need to look like, that I can transfer larger files.
Thanks in advance
Regards Markus
The service now publishes the endpoint using ProtocolMapping section, I suggest you name the binding and apply the configuration to the properties below.
<bindings>
<basicHttpBinding>
<binding name="mybinding" ... >
...
</binding>
</basicHttpBinding>
</bindings>
<protocolMapping>
<add binding="basicHttpBinding" scheme="http" bindingConfiguration="mybinding"/>
</protocolMapping>
If it doesn’t work, we could publish the service by using the following style.
<system.serviceModel>
<services>
<service name="WcfService1.Service1">
<endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1" bindingConfiguration="mybinding"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
</service>
</services>
Feel free to let me know if the problem still exists.
I have a C# application which is using Travelport Universal API interfaces through SOAP communication.
In C# I used the wsdls for generating the SOAP client.
I have this config settings for HTTPS connection (this was generated by Visual Studio from WSDL):
<system.serviceModel>
<bindings>
<basicHttpsBinding>
<binding name="AirLowFareSearchBinding" maxBufferSize="2097152" maxReceivedMessageSize="2097152">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpsBinding>
</bindings>
<client>
<endpoint address="https://emea.universal-api.travelport.com/B2BGateway/connect/uAPI/AirService" binding="basicHttpsBinding" bindingConfiguration="AirLowFareSearchBinding" contract="AirServiceReference.AirLowFareSearchPortType" name="AirLowFareSearchPort" />
</client>
About this SSL3.0 vulnerability Travelport want to disabling SSL3, and I could use just over TLS.
My question is what should I change on this config, or should I change anything for TLS connection on https instead of SSL3.
In you code before calling to the service:
system.Net.ServicePointManager.SecurityProtocol=SecurityProtocolType.Tls12;
Here is a blog post Here
I've been struggling for a few hours I admit. I must be missing something with the Bindings/Configuration between my Silverlight application and WCF web service. It was working for awhile, but I must have accidentally changed some settings and I can't get it to work anymore.
In Visual Studio when I debug I have both the Service and Silverlight application launch at the same time, I have Windows authentication disabled in the web.config files for debugging. When I deploy, I go back and change my Configuration files to enable Windows security/transport so I can get user credentials on the web service side.
Now when I deploy both the WCF service and the Silverlight application to a different machine using IIS, I get an error "Not Found" from Silverlight when it attempts to contact the WCF service. Could someone explain to me the different configuration files that exist and what each should be pointing to? Here are my configuration files in their respective locations:
wwwroot\webserviceapp\web.config
<?xml version="1.0" encoding="UTF-8"?>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpointBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="WebserviceName.Service1">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="BasicHttpEndpointBinding"
name="BasicHttpEndpoint" contract="WebserviceName.IService1">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
wwwroot\web.config - this is the web.config for silverlight I guess?
<?xml version="1.0" encoding="UTF-8"?>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpoint" 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="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://<<<ip_to_machine>>>/webserviceapp/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpEndpoint"
contract="ServiceReference1.IService1"
name="BasicHttpEndpoint" />
</client>
</system.serviceModel>
<system.webServer>
<defaultDocument>
<files>
<add value="ProjectTestPage.html" />
</files>
</defaultDocument>
</system.webServer>
wwwwroot\ClientBin\SilverlightApp.xap (the ServiceReferences.ClientConfig file):
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpoint" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="TransportCredentialOnly" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://<<<ip_to_machine>>>/webserviceapp/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpEndpoint"
contract="ServiceReference1.IService1"
name="BasicHttpEndpoint" />
</client>
</system.serviceModel>
These are the three configuration files which seem to drive everything, unless I am wrong? Since I develop on one environment and deploy to another it seems like I must change these files to point to the right resources. When I hit my Silverlight application after I've deployed it to the new machine I get the application loading. Once it finishes loading, the first web service call it makes fails with exception and I get this in the Chrome Console:
Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://<<<ip_to_machine>>>/webserviceapp/Service1.svc
Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://<<<ip_to_machine>>>/webserviceapp/Service1.svc
Uncaught Error: Unhandled Error in Silverlight Application An exception occurred during the operation, making the result invalid. Check InnerException for exception details. at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at Project.ServiceReference1.GetAllNewsCompletedEventArgs.get_Result()
at Project.View.Home1.ClientGetAllNewsCompleted(Object pSender, GetAllNewsCompletedEventArgs pEventArgs)
at Project.ServiceReference1.Service1Client.OnGetAllNewsCompleted(Object state)
I'm like 99% certain that the Service is NEVER hit. I have a log statement at the very top of the function which is being called and it never logs anything.
IIS Configuration:
Web Service Authentication:
Anonymous = Disabled
ASP.NET Impersonation = Disabled
Windows Authentication = Enabled
Default Web Site (where my silverlight app is hosted):
Anonymous = Disabled
ASP.NET Impersonation = Disabled
Windows Authentication = Enabled
Anyone have any suggestions, or need anymore information from me to help debug?
EDIT: It is worth noting that I am able to navigate to the service from a different machine and see the service wsdl just fine. For example:
http://ipaddress/webserviceapp/Service1.svc
I can see this just fine, no errors.
I think the answer is pretty simple. The error I was receiving is a very generic error. The proper thing to do in this instance is to use Fiddler which will tell you EXACTLY what the error is. In my case, Trace logging wasn't working properly due to the service not loading properly. However, Fiddler was able to give me the exact exception messages which led me to resolve the problem quickly and easily.