Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all 555 articles
Browse latest View live

Wcf IErrorHandler extensibility

$
0
0

Hi to all!

I have this question, I extended WebBehaviour in a WCF service, and all works good!!

now i wat to give this behaviour to all other services, so i created a ClassLibrary project, and placed the extended classes in this library project.

The problem is that this way it show an config error message "...'WebBehaviorExtension' could not be loaded."

I changed the configuration in web.config but thi problem continues

Anyone has idea what I'm doing wrog?

Thanks in advance


Windows Service Using FluentNhibernate

$
0
0

Hi Friends,

I'm facing an error in windows service, I am using windows service and Database-> FluentNhibernate. First I'm not Include the Mappings files the windows service was works fine (Installed). But When i include the Mappling Files windows service was not installed. Please Help me in this.

webservice problem

$
0
0

I am calling a webservice which is hosted on a server, locally....

I know that one method in that webservice returns a dataset....bt when I debug it shows nothing in vb.net....

What do I need to do so that I can debug my application locally and also fetch the data that I am seeking from the webservice....

How to Generate Web References without using Visual Studio

$
0
0

Dear ASP.NET Forum,

I am new to this (Web API) forum and I hope that this message is going into the right place.

I have little or no experience with WCF, but I have had some experience with writing a web service whereby it is being consumed by another organisation.

In my current project, we separated the Web and App tier with the use of a number of web services. All this is well-and-nice with the help of Visual Studio, where it conveniently creates Web References for our Web tier (to consume the services on the App tier). However, when it comes to deploying the compiled binaries into a UAT environment (and subsequently a Production environment), we are unable to change these Web References as they are in a compiled and stored in "App_WebReferences.compiled" and "App_WebReferences.dll". And as such, the web tier cannot "reach" the web services.

I believe this problem can be overcome if we can find a way to generate web references without using Visual Studio; or is there another way?

Any assistance will be well appreciated.

Thank you.

How to call webservice from different project using Jquery ,Asp.net,C#

$
0
0

Dear friends ,

I have two Project one is Web Service and i want to use this web service from another project using JQUERY,ASP.Net,C#

Invalid Token

$
0
0

Hi

I have a third party secure webservice which i call in my internal webservice.

My internal webservice is like this when i call this i m getting invalid token, any idea what is causing it, there is no session timeout and the third party service works fine on their end.

<WebMethod()>
    Public Function sstest1() As String

        Dim Str As String

        Dim token As String

        Dim bauth As New AuthenticationAPIWebService
        Dim bauthresult As New AuthenticateResult
        Dim myProxy As New System.Net.WebProxy("http://91.1.15.3:8080", False)

        myProxy.Credentials = New System.Net.NetworkCredential("xxp", "Vf72CwMSvB72rk", "xx.com")
        bauth.Proxy = myProxy
        bauthresult = bauth.Authenticate("xx", "xx")

        bauth.PreAuthenticate = True

       token = bauthresult.Token.TokenString

str = "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" "

        Str = Str + "xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"

        Str = Str + "<soap:Body>"      

        Str = Str + "<ServiceRequest_Create xmlns=""http://systems.com/ServiceRequest_Create""

        Str = Str + "<token>" + token + "</token>"

        Str = Str + "<objCreateServiceRequest>"

        Str = Str + "<UPRN>000021089821</UPRN>"

        Str = Str + "</objCreateServiceRequest></ServiceRequest_Create></soap:Body></soap:Envelope>"

Dim req As System.Net.HttpWebRequest = System.Net.WebRequest.Create("https://systems.com/wcapi.asmx")       

req.ContentType = "text/xml;charset=utf-8"

        req.Accept = "text/xml"

        req.Method = "POST"

        req.Proxy = myProxy

        Using stm As Stream = req.GetRequestStream()
            Using stmw As New StreamWriter(stm)
                stmw.Write(Str)
            End Using
        End Using

Dim response As System.Net.HttpWebResponse

response = req.GetResponse()

Dim reader As New StreamReader(response.GetResponseStream())

Return reader.ReadToEnd()

End Function


Any help appreciated, The xml response which i get is "Invalid Token",

Thanks

Srini

Dual Communication

$
0
0

I want suggestion regarding architecture/technology for following scenario :

I have to develop an application in which one side there will be a Instructor and one side student.

Consider, Instructor's page will have some buttons, when instructor will click first button some content related to first button will get loaded on student page from centralized database.

Similarly when instructor will click second button some data related to second button will get loaded on student page from database.

So, i need suggestion/samples/links regarding technology to make it possible with ease/fast/reliable

maybe i need dual communication using wcf and etc.....

How to use resource file in WCF

$
0
0

HI,

How to use resource file in WCF,

Can anybody provide an example.

is there any disadvantage of using resouce file in wcf?


ASP.net web service using javascript to send commands

$
0
0

I am looking to send commands to a web service page on my local network via javascript that's being used on a WebOS tablet. Problem being is that I've never done this before and was wondering if it was even possible to do in the first place? Is it possible for me to create a VB.net to listen to a web service call/webpage?

I would be creating the "app" from phonegap using Dreamweaver. I am looking for examples of using javascript to send over a string to a web service that i can read constantly on the PC in order to preform tasks as needed depending on the button i push on the app.

So as an example:

WebOS app >
button pushed in app to call up Internet Explorer >
sends "IE" string to WS >
WS triggers the correct exec to start depending on the string sent to it (IE) >
WS sends back "OK" to WebOS app when program is launched

Does anyone have an example of something like this?

My HTML page looks like this (localhost://testJS.htm):

<!DOCTYPE html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">

function buttonClicked(what2Pass)
{
  $.ajax({
    async : false, /* set as true if you want asynchronous behavior */
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: "WebService.asmx/PerformAction",
    data: { "webOSCommand" : what2Pass},
    dataType: "json",
    success: function(data){
        alert(true);
    }
  });
}

<html>
<body>
<input type="button" id="button1" value="run IE on PC" onClick="buttonClicked('IE');" />
</body>
</html>

and for my WS it would be:

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Diagnostics
Imports System.Web.Script.Services

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class Service
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function PerformAction(byRef webOSCommand as String) As String
        Dim oPro As New Process

        With oPro
            .StartInfo.UseShellExecute = True
            .StartInfo.Arguments = "http://www.google.com"
            .StartInfo.FileName = "internet explorer.exe"
            .Start()
        End With

        Return "Started"
    End Function
End Class

And now i am getting the error: Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)

How to return list from wcf to silverlight file

$
0
0

Hi 

WCF -

public List<Department> department_names()
{
List<Department> list = new List<Department>();
string deptnames = "Select dept_id,department_name from Department";
con.Open();
DataRow r = null;
cmd = new MySqlCommand(deptnames, con);
da = new MySqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds, "Department");
dt = new DataTable();
dt = ds.Tables[0];

foreach(DataRow d in dt.Rows)
{
Department dpt = new Department();
r = d;
dpt.dept_id = Int32.Parse(r[0].ToString());
dpt.dept_name = r[1].ToString();
list.Add(dpt);

}
con.Close();
return list;

}

here Department is a class of get and set.

in service.cs

[OperationContract]
List<Department> department_names();

Now in.cs file

I tried to retrieve like below

var d = new ServiceReference1.LibrayClient();
d.department_namesCompleted += new EventHandler<ServiceReference1.department_namesCompletedEventArgs>(department_names);
d.department_namesAsync();

void department_names(object sender, ServiceReference1.department_namesCompletedEventArgs e)
{

e.result;

}

I want to retreive the list ?

HttpContext.Current is null

$
0
0

I am using WCF Service in which i use HttpContext.Current in class and find that the "HttpContext.Current is null"

Please help me to know what is the alternative of this ....

Lists ASMX sharepoint web service

$
0
0

Hi all, I'm trying to connect to the sharepoint web service and output the data of a list, if I use GetList it seems to retrieve some info ok. but when trying to use GetListItems to output the data of a list I get blank data. My code is as follows:

 

<script runat="server">

 private void button1_Click(object sender, EventArgs e) {

 // Display the greeting label text.
GreetingLabel.Visible = true;

string listGUID = "xxxxx-xxx-xxx-xxxx-xxxx";

StringBuilder sbEnvelope = new StringBuilder(); sbEnvelope.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); sbEnvelope.Append("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " + "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"); sbEnvelope.Append(string.Format( "<soap:Body>" + "<GetListItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">" + "<listName>Student Handbook</listName>" + "<viewName></viewName>" + "<viewFields><ViewFields xmlns=''><FieldRef Name='Chapter' /><FieldRef Name='Section Title'/></ViewFields></viewFields>" + "<rowLimit>100</rowLimit>" + "</GetListItems>" + "</soap:Body>", listGUID)); sbEnvelope.Append("</soap:Envelope>");    try {

HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://server/_vti_bin/Lists.asmx");

 

req.Method = "POST"; req.ContentType = "text/xml; charset=\"utf-8\""; req.Accept = "text/xml"; req.Headers.Add("SOAPAction", "\"http://schemas.microsoft.com/sharepoint/soap/GetListItems\""); req.UseDefaultCredentials = true;   using (Stream stream = req.GetRequestStream()) { using (StreamWriter writer = new StreamWriter(stream)) {

writer.Write(sbEnvelope.ToString());

} }

WebResponse response = req.GetResponse(); Stream responseStream = response.GetResponseStream();   XmlDocument xDoc = new XmlDocument(); xDoc.Load(responseStream); XPathNavigator xNav = xDoc.CreateNavigator(); GreetingLabel.Text += xNav.OuterXml.ToString(); } catch (Exception ex) { GreetingLabel.Text = sbEnvelope.ToString() + "\r\n----\r\n" + ex.ToString(); } }

</script>

 

can anybody help?! thanks

 

 

SOAP envelope request and get respose using c#

$
0
0

I have third party company given us URL and SOAP envelop format , now I need to request i have used below method but gives me errors.

I have string soapenv =

 HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://thirdparycompanydom.com/");
                req.Headers.Add("SOAPAction", "\"http://tempuri.org/Register\"");
                req.ContentType = "text/xml; charset=\"utf-8\"";
                req.Accept = "text/xml";
                req.Method = "POST";

                using (Stream stm = req.GetRequestStream())
                {
                    using (StreamWriter stmw = new StreamWriter(stm))
                    {
                        stmw.Write(soapenv);
                    }
                }

                WebResponse response = req.GetResponse();
               
                StreamReader responseStream =new  StreamReader(response.GetResponseStream());
                lbl.Text = responseStream.ReadToEnd();
                responseStream.Close();


this gives me error

System.Net.WebException: The remote server returned an error: (500) Internal Server Error

what it could be, do you think my code have erros

WCF Data Limitation Error Message

$
0
0

I have a MVC3 page that is consumed a WCF Service. It worked fine for small amount of data; however, it closed the connection when I have large amount of data. For example, it worked fine for 2000 records, but it did not work for 3000 or more. Has anyone else came across this issue or have fixed it before? The issue is only when I am calling the method through the webservice. If I create a method and call the method outside of the webservice, it load the data without issues.

See custom binding below

<bindings>
      <customBinding>
        <binding name="WSHttpBinding_IDALContentManager" closeTimeout="00:30:00" receiveTimeout="00:30:00" sendTimeout="00:30:00">
          <textMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647"
            messageVersion="Soap12" writeEncoding="utf-8">
            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
              maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          </textMessageEncoding>
          <httpTransport manualAddressing="false" maxBufferPoolSize="2147483647"
            maxReceivedMessageSize="2147483647" allowCookies="false" authenticationScheme="Anonymous"
            bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
            keepAliveEnabled="true" maxBufferSize="2147483647" proxyAuthenticationScheme="Anonymous"
            realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
            useDefaultWebProxy="true" />
        </binding>

      </customBinding>

    </bindings>



Consume WCF Service from Windows Service

$
0
0

Dear all,

We host a WCF Service in IIS on an external webserver reachable on the internet.
First I created a c-sharp ‘windows application’ to consume the WCF Service. Running the application and reaching/calling the WCF Service from within our office and outside works great.

Now we decided a c-sharp ‘windows service’ would be better to consume the WCF Service.
Adding the Service Reference, creating the proxy class etc all works fine. But when I install the windows service (using a installer) we have problems reaching the WCF Service.

From within our company’s network I get the following error message:
“There was no endpoint listening at https://www.mywebsite/MyService.svc/MyService.svc that could accept the message. This is often caused by an incorrect address or SOAP action.”

Inner exception:
“Unable to connect to the remote server”

Inner Exception:
“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 xx.xxx.xxx.xx:443”

When I use the same installer and install the service on my home computer, reaching/calling the WCF Service works great.

Does anybody know what could cause this problem?

Thanks in advance!


Invalid XML document.

$
0
0

I am using WCF service trying to save xml file, but getting the error

Invalid XML document. The document does not have a root element.

xdHeadera.Save(System.Web.Hosting.HostingEnvironment.MapPath("~/" + fName));



bool return value problem

$
0
0

Hi

my code

bool user_check

private void btnsignin_Click(object sender, RoutedEventArgs e)
{

WCFServiceLibrary.LibrayClient check_user = new WCFServiceLibrary.LibrayClient();
check_user.check_user_nameAsync(txtusername.Text);
check_user.check_user_nameCompleted += new EventHandler<WCFServiceLibrary.check_user_nameCompletedEventArgs>(getbool_user);

if (user_check == true)
{
MessageBox.Show("hi");
}

}

void getbool_user(object n, WCFServiceLibrary.check_user_nameCompletedEventArgs e)
{
user_check = e.Result;
}

my code is correct. But there is one problem

To get the return value i have to click 2 times of submit button

how to solve it

Thanks in advance

List cannot be serialized because it does not have a parameterless constructor

$
0
0

I'm maintaining  a web application.  I've found I need to create a new webservice.  However, I didn't write any of  the original webservices, so I've been blundering along.  I'm pretty sure I've got the code right, but I've run into a snag...

I'm getting an error and can't figure out how to fix it...  The error is: [GPService.DataEntity.MuniAuthList] cannot be serialized because it does not have a parameterless constructor.

So, I go to GPService.DataEntity.MuniAuthList and there IS a parameterless constructor.  Code is as follows

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;

namespace GPService.DataEntity
{
    
    #region MuniAuth
    public sealed class MuniAuth
    {

        public MuniAuth() { }
  
        [DataMember]
        public string Account
        {
            get;
            set;
        }

   
        [DataMember]
        public string MUNIID
        {
            get;
            set;
        }

      
        [DataMember]
        public string Muniname
        {
            get;
            set;
        }
        [DataMember]
        public string Assessment_reports
        {
            get;
            set;
        }
        [DataMember]
        public string Owner_info
        {
            get;
            set;
        }
        [DataMember]
        public string Tax_info
        {
            get;
            set;
        }
        [DataMember]
        public string MLS_listing
        {
            get;
            set;
        }
        [DataMember]
        public string Blueprints
        {
            get;
            set;
        }
        [DataMember]
        public string Prop_images
        {
            get;
            set;
        }
        [DataMember]
        public string Fire_plan
        {
            get;
            set;
        }
    }
     
   
    [CollectionDataContract]
    [KnownType(typeof(MuniAuth))]
    public sealed class MuniAuthList : BaseCollection<MuniAuth>
    {
       
        public MuniAuthList() {}
        
       
        [MessageBodyMember]
        public IList<MuniAuth> Collection
        {
            get { return base._list; }
            set { base._list = value; }
        }
        
       
    }

    #endregion
}

The code for the service is laid out in several files, Service, BusinessLogic, DataAccess and DataEntity.  I've based the code for this service on the other services and they work fine.  HOWEVER, ther are .svc files and the new one is a .asmx file. It's also possible I'm not building something correctly and I didn't know, but when I've made changes to the existing services, they went through fine, so I kinda doubt that...

If you have any suggestions, I'd appreciate it.  I've tried everything I can think of.

WCF service client

$
0
0

Hi

I have the following design:

Data class library (class project) utilizing Microsofts Enteprise Library Data Acess Block.

Service Library (class project) where I have defined my datacontract, service contract, operation contract

Asp.net c# website 

Now In asp.net website code behind I want to call the method I created to fillup my grid.

So I wanted to know how should I create my client and call my method in service library

Thanks

SOAP Header Authentication not working?

$
0
0

Im using a SOAP Header and I need to Authenticate it from the Database. So, I tried creating one Class and have one method on which, when we pass username and password it will return whether its there in the DB or not.

----- My Main Class ---
[WebMethod, SoapHeader("AuthenticateUser")]
public System.Xml.XmlElement CancelUSer(string _UserID, string _Remarks)
{

if (UsersAuth.ValidateUser(AuthenticateUser.UserName, AuthenticateUser.Password) > 0)
{
//METHODS

}
}
--------------------------

//Soap Header
public class UserAuthenticateHeader : SoapHeader
{
public string UserName;
public string Password;
}

//Class written for Authentication
public class UsersAuth
{
static OracleConnection con;
public UsersAuth()
{
con = new OracleConnection(WebConfigurationManager.ConnectionStrings["conString"].ToString());
}




public static int ValidateUser(string _UserName, string _Password)
{
int Result = 0;
using (OracleCommand cmd = new OracleCommand("SELECT COUNT(*) FROM USES WHERE UID=:UID AND PASSWORD=:PASSWORD", con)) {
cmd.Parameters.AddWithValue(":UID", _UserName);
cmd.Parameters.AddWithValue(":PASSWORD", _Password);
con.Open();
Result = Convert.ToInt32(cmd.ExecuteScalar());
con.Close();
}
return Result;
}
}



Now, When I call this from my program its throwing he ObjectReferenceNotSet to an instance of an object. I have set username, passsword and Headervalue for the method from the application. But its not hitting the "ValidateUser" Method.

Is there any way on which I can achieve this?

Viewing all 555 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>