I read about not being able to call .asmx outside the application domain unless through a Proxy. Is a class library outside the application domain? If not, how do I get Jquery to see it.
Based on my understanding, first you don't need to create webservice in the class library, since class library is not based web application, so it is not very easy to create webservice, and consume it using jquery, it seems class library doesn't like web
application, so it doesn't exist cross domain access. I recommend you'd better place or create your webservice in the web application instead of classlibrary.
Ive moved the exact same WebService into the Web Application Project...and it works
Once I move it to a Class Library outisde...I cant seem to reference it / find it.
If you want to put the webservice in the classlibrary, you could try placing the Webservice2.asmx.cs file in the class library and place the Webservice2.asmx file in the web application project, and then using jquery to consume it in the ObjectManager.aspx
nischal.bach...
Member
3 Points
5 Posts
Is it Possible to call .asmx from separate class library in Web Application Solution
May 19, 2012 11:32 PM|LINK
Below is a structure of my asp.net Solution:
Solution_My_Site
|__Web_Application_Project
| |__ObjectManager.aspx
| |__ Webservice1.asmx
| |__web.config
| |__ObjectManager.master
|__Class_Library
|__Webservice2.asmx
Question
Using Jquery I can successfully call WebService1.asmx from ObjectManager.master
Is it possible to call Webservice2.asmx?
I have the [System.Web.Script.Services.ScriptService] tag in WebService1.asmx
and
I use the following Jquery in ObjectManager.master
function Greeting() { $.ajax({ url: "/WebService1.asmx/HelloWorld", type: "POST", data: "{}", dataType: "text", success: Success, error: ajaxFailed }); }I read about not being able to call .asmx outside the application domain unless through a Proxy. Is a class library outside the application domain? If not, how do I get Jquery to see it.
Peter pi - M...
Star
12871 Points
1786 Posts
Re: Is it Possible to call .asmx from separate class library in Web Application Solution
May 21, 2012 05:33 AM|LINK
Based on my understanding, first you don't need to create webservice in the class library, since class library is not based web application, so it is not very easy to create webservice, and consume it using jquery, it seems class library doesn't like web application, so it doesn't exist cross domain access. I recommend you'd better place or create your webservice in the web application instead of classlibrary.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework
nischal.bach...
Member
3 Points
5 Posts
Re: Is it Possible to call .asmx from separate class library in Web Application Solution
May 21, 2012 06:53 AM|LINK
Im trying to seaparate Application Logic into different class libraries (reusability)
I have all data access logic in one clas slibrary, business logic in another etc.
Now I want the webServices in their own class library...not in the Web Application Project/ UI Frontend.
I Tried the Following
Adding a Service Reference to my Web App project....this created a Proxy in the web.config...GREAT!
<system.serviceModel> <bindings> <basicHttpBinding> <binding name="ObjectManagerSoap" 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="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://localhost:5839/ObjectManager.asmx" binding="basicHttpBinding" bindingConfiguration="ObjectManagerSoap" contract="ServiceReference1.ObjectManagerSoap" name="ObjectManagerSoap" /> </client> </system.serviceModel>Now I try to use the following Jquery to consume it
function Greeting() { $.ajax({ url: "http://localhost:5839/ObjectManager.asmx/HelloWorld", type: "POST", data: "{}", dataType: "xml", success: Success, error: ajaxFailed }); }Function Ajax Failed returns
0 Error
function ajaxFailed(xmlRequest) { alert(xmlRequest.status + ' \n\r ' + xmlRequest.statusText + '\n\r' + xmlRequest.responseText); }Ive moved the exact same WebService into the Web Application Project...and it works
Once I move it to a Class Library outisde...I cant seem to reference it / find it.
Peter pi - M...
Star
12871 Points
1786 Posts
Re: Is it Possible to call .asmx from separate class library in Web Application Solution
May 22, 2012 03:26 AM|LINK
If you want to put the webservice in the classlibrary, you could try placing the Webservice2.asmx.cs file in the class library and place the Webservice2.asmx file in the web application project, and then using jquery to consume it in the ObjectManager.aspx
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework