WCF Service in Windows Phone Silverlight 8.1 Project - web-services

I cannot seem to access my WCF Service from Windows Phone Silverlight 8.1 application.
I am able to add a service reference, like for example in a console applications, but the following code does not work
ServiceReference1.MojaSmetkaWcfClient client = new MojaSmetkaWcfClient();
var result = client.GetData(0);
It says 'Cannot resolve symbol ServiceReference1'.
This works in a console app project. How can I connect to the WCF service. If it is not possible, are there any alternatives similar to WCF? Thanks

I have solved this by updating my VS2013 to Update 5 (maybe that didn't help solving the problem) and doing the following:
Right click on the service reference
Configure service reference
Uncheck 'Reuse types in referenced assemblies'

Related

How to consume credential based webservice (asmx) in Asp.net Core web application?

I am facing issue while adding asmx service in .NetCore Console application. I am using WCF Connected Service extension as add web reference is not available. So,I followed the same steps which was suggested in following link
https://blogs.msdn.microsoft.com/webdev/2016/06/26/wcf-connected-service-for-net-core-1-0-0-and-asp-net-core-1-0-0-is-now-available/
After completing all step it provided auto-generated reference class which contains all method as async method. My asmx service required username and password authentication for each method and we pass credential as first parameter of any method.
for example, using web reference my method looks like GetData(Credential credential) but here auto generated class shows this method like
GetDataAsync() so I used the below mention code to pass the credentials before calling my web service method
client.ClientCredentials.UserName.UserName = "myusername";
client.ClientCredentials.UserName.Password = "mypassword";
It's giving me Not Authorized error, after putting the breakpoints I found that credential was not getting at asmx service.
Please suggest some solution.
Previous Approach I Took:
I ran into a similar issue. I have an MVC Core web application (targeting .NET Framework 4.6.1) and was not able to add a Web Reference the way I used to be able to within previous (non-Core) applications. I was not able to get Connected Services to add a reference to an asmx and allow for the passing of credentials.
To work around this, I created an additional project (a class project also targeting .NET Framework 4.6.1). From there I was able to add a Web Reference the way one could in the past. Within this project I created a class with a publicly accessible method that calls the asmx service.
Then, within my MVC Core project, I set a reference to this additional project and am able to call the public method on the other project.
Latest and Best Approach I Have Found:
I fully updated VS 2017 as well as going to this site to get the latest WCF Connected Services extension (https://marketplace.visualstudio.com/items?itemName=WCFCORETEAM.VisualStudioWCFConnectedService).
The AuthorizationSoapHeader was easy to access and set.
MySoapClient.EndpointConfiguration endpoint = new MySoapClient.EndpointConfiguration();
MySoapClient myService = new MySoapClient(endpoint, myURL);
AuthorizationSoapHeader MyAuthHeader = new AuthorizationSoapHeader();
MyAuthHeader.AppName = FDSServiceAppName;
MyAuthHeader.AppID = Guid.Parse(MyAppID);
Entry[] entries = MyService.GetUsers().Result;
I faced the same problem and i resolved it owning to github issues :
In Reference.cs substitute
System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding()
for
System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly);
result.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Basic;
This really worked in .net core client app for soap web services

Need Suggestion on How to get data from SharePoint Online for Windows 8.1 App

I recently working on a Windows 8.1 App, which was developed with C# and XAML. SharePoint Online is used for Data store.
I searched and found that Wictor solution can be used for Authentication. but the problem is that we can not use Wictor solution [http://www.wictorwilen.se/Post/How-to-do-active-authentication-to-Office-365-and-SharePoint-Online.aspx] directly as it is built upon .Net framework and Metro Apps are built upon .NetCore.
One possible option is to use WCF service and have whole Wictor solution in WCF service then call WCF service from Windows App. I tested it and it is working fine.
However, I wanted to know what would be the best approach available if I don't want to deploy this WCF separately. In future I have to publish this Win App on Windows store.
Any help will be appreciated.
Thanks

ASP.NET Web Service returning Bad Request in Windows Azure

After a Windows 7 fresh restart, I open the Visual Studio 2010 as administrator, create a new project of Windows Azure Project with ASP.NET Web Role, then at the WebRole1 project I add a WebService1.asmx and press F5 (run).
The Windows Azure services starts OK and the browser open the http:/127.0.0.1:8080/WebService1.asmx perfectly. But when I click at Invoke button to test the webservice method I always receive a Bad Request - Invalid Hostname, with a http:/127.0.0.1:8081/WebService1.asmx/HelloWorld.
The most likely cause is ASMX's WSDL file doesn't stand by load balanced environment such as Windows Azure. The test feature relies on WSDL. You will see similar issues if you add a web/service reference. It is recommended to upgrade to WCF. In WCF, you can use useRequestHeadersForMetadataAddress (http://msdn.microsoft.com/en-us/library/ee816894.aspx) to fix the issue. If you need to use ASMX, please try to manually provide a correct WSDL file.

Web service on iis not updated

I deployed a web service to iis 7, it was working all the way right.
Then I wanted to update the code of a web method in the web service.
I recompiled the service and updated the dll in the iis directory with the new one.
My problem is when I invoke the service, it invokes the older code.
I tried changing the number of parameters passed to a web method inside the service, and when invoking it still sees the older parameters which I erased.
Web services after Framework 2.0, are compiled as DLL files by default as far as I know. Normally, this happens when you PUBLISH the website and webservice, or when you use Web Applications.. But in WebServices, Visual Studio compiles the output as DLL. Therefore, you should compile your dll and update on the IIS. Even though you see the CS code files on IIS folder, they are not being used. Only the asmx file (not asmx.cs) are used to map the code in the dll.
I am guessing that the old code is cached. Try restarting IIS. That should cleanup any remnants of the old code.
It seems that you need to update your service reference.
Go to the project who's using the service, left-click the service reference in your solution explorer and finally choose "Update Service Reference".
Maybe I'm wrong and you did it, but as you don't mention that in your question, this is my suggestion.
rebuild the solution, And deploy the service on IIS. It will work definitily

How can I add a web service project using Visual Studio 2010?

I don't want WCF, I only want web service.
Thank you.
They've obscured it, but it's easy enough:
Right-click on your solution, select Add New Project.
In the Framework selection dropdown, select .NET Framework 3.5
Select the Web installed templates listing and you'll find ASP.NET Web Service Application as the last one in the list.
In other words, you can create one in .NET 3.5, but not 4. Now, that being said, it seems like it may be possible to create a .NET 4 template for VS2010, but I'm not a VS2010 guru, so that's for someone else to elaborate on.
Edited to Add: Somebody else posted a response to your question that was also a good answer, I thought, but they deleted it themselves for some reason. I don't remember their user name. I'll repeat it here.
If you create a new Web Application in the solution, you can then Add New Item, and one of the options under Web is "Web Service" at the very bottom.
The only drawback to this is that besides the web service, you also have the usual default items for a web application, namely default.aspx, about.aspx, global.asax, and site.master, as well as the folders Account, Scripts, and Styles. But you can delete these, so no problem. Also keep in mind that the web.config in the Web Application project will be different from that of the Web Service, and that the assembly bindings for the web service will point to ASP.NET v2 & v3.5 (see its web.config), whereas the service in the web application project will default to ASP.NET v4 (through its project file). I don't know if any negative implications exist for either way of working, though I suspect that both will work just fine.
If you select the framework like mentioned above to 3.5 you can select a web service application. If you want it to be targeted at .NET 4.0 framework, go into my project --> Compile --> Advanced Compile Options --> change the target framework to .net framework 4.
You can also change your compile options to target it at a x64 or x86 (32 bit) server.
web.config in the Web Application project will be different from that of the Web Service, and that the assembly bindings for the web service will point to ASP.NET v2 & v3.5 (see its web.config), whereas the service in the web application project will default to ASP.NET v4 (through its project file). I don't know if any negative implications exist for either way of working, though I suspect that both will work just fine.
Here was my resolution:
Right-click on your project name and select to Add Service Reference.
Select the Advance button at the very bottom.
Select the Add Web Reference button at the very bottom.
Proceed as usual. :)