calling wcf service through Java script - asp.net-mvc-3

I am using vs 2010- mvc3 with aspx (not raiser type).
I try to use web service through J sciprt, but i got error unknown method.
In my privious project (mvc) using web serive (asmx); using asp:ScriptManager working fine

http://dotnetbyexample.blogspot.com/2008/02/calling-wcf-service-from-javascript.html
http://www.codeproject.com/KB/aspnet/wcfinjavascript.aspx
Invoking WCF Service through Javascript
and many more...

Related

Service Layer with WebApi

I am starting to work on a new project so working on laying on the architechture at this moment.
So basically we want to keep a service oriented architecture using MVC web api.
So I had the following structure in mind:
Project.Core (All Poco classes)
Proect.Data (All entity framerwork)
Project.Service (All Web API ??)
Project.Web
We would be working for the first time on webapi here. So wanted to know how do we intergrate webapi here.
Most of the articles we saw read had created a mvc web application and had selected webapi in that. But we
were looking to create separate service layer just for webapi. Is this the correct practice to do that or
I am missing something here.
We basically wanted not to have a tight coupling b.w MVC web and web api here. If we create web api as part
of mvc then how can we separately access our web api.
WOuld appreciate inputs.
I normally use the project template provided by Visual Studio. Choose Empty ASP.NET project template and then select Add folders and references for Web API. It will create the folder structure needed/recommended purely for a Web API project without any MVC reference. I generally create a separate project for Data Access and use that from the Web API project.

Best way to consume WCF Service inside ASP MVC3 app

I am new to the world of WCF and MVC. Currently I have a MVC3 ASP application and a WCF service app exposing some services. I want access this service from MVC3 ASP app. As I know either this can be done by adding the Service Reference to ASP project or by generating proxy class from WCF service and add proxy class to ASP app.
My question: Is it the right way I am going (as said above). If so which method is better (adding service reference or generating proxy class and adding it manually)?
It is a lot easier to use add service reference. Add service reference basically means that you are asking visual studio to do the job that you would have done if you were generating it manually with default settings.
If you don't have any reason not to go the easier way, then my advice is to use add service reference.

Add WCF Service Reference to Umbraco

Im currently using Umbraco 4.11 that is integrated to an asp.net mvc 3 application. Im trying to reference a wcf service in the umbraco project by selecting Add Service Reference in visual studio but I can not seem to access the service library once it is added. I tried to look into the object view browser and I couldn't find the object namespace for the wcf service. Am I missing something? Is this method of consuming wcf service in umbraco possible? I prefer not to use a separate project that uses a user control to access the wcf service since it seems to be tedious to do.
There is a warning when adding a service reference:
Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Could not load file or assembly 'umbraco, Version=1.0.4090.38017, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
You may want to setup the service reference in a separate project, then migrate the dll and the web.config settings. Then you should be able to access your web service via razor after adding using statements.
The problem is that the code file for the service isn't being generated because of a conflict with umbraco. You could alternatively generate the code file manually using svcutil.exe.

ASP.NET MVC 3 and WSE 2.0

I've an ASP.NET MVC 3 project and have been tasked with implementing a few UI controls. I need to call a few web services and bind the data to the UI controls. The problem is the web services host (we have no control over them) requires me to first implement a UsernameToken class (WSE 2.0) to authenticate the user and generate a security token. I understand WSE 2.0 is superceded by WCF in 2006. I don't want to switch back to VS 2005 to be able to use WSE 2.0. What are my options?
Thanks for any help!
Just add a Service Reference to your ASP.NET MVC application and point it to the web service WSDL. This will generate a strongly typed WCF client which is compatible with WSE. Here's an article which covers the different interoperability scenarios
I'm afraid the approach Darin Dimitrov didn't work. What I have ultimately done is installed WSE 2.0, then added dll reference to Microsoft.Web.Services2.dll found in the WSE installtion directory (c:\Program Files (x86)\Microsoft WSE\v2.0\Microsoft.Web.Services2.dll). I also modified the Reference.cs file of the service to inherit from Microsoft.Web.Services2.WebServicesClientProtocol. I was able to find the UsernameToken class and able to authenticate successfully.
I'm not an expert in this area so I'm not sure if this is the correct way of doing this, but it worked nonetheless.

How do you stop a Visual Studio generated web service proxy class from encoding?

I'm using a Visual Studio generated proxy class to access a web service (added the web service as a web reference to my project). The problem is that the function the web service exposes expects a CDATA element, i.e.:
<Function><![CDATA[<Blah></Blah>]]></Function>
Unfortunately, when I pass in "" into the proxy class, it calls the web service with this:
<Function><![CDATA[<Blah></Blah>]]></Function>
This appears to be causing problems with the web service. Is there any way to fix this while still using the proxy class generated by Visual Studio?
Can you provide a code sample of how you're calling the webservice? If it's a web service with a published WSDL I don't know why you'd even have to address this level of implementation detail, so I have a suspicion that you're calling it wrong somehow.

Resources