Click here to Skip to main content
15,890,579 members

Comments by Ramya singam (Top 5 by date)

Ramya singam 21-Feb-13 5:40am View    
no..I have used the web service like

string url = "http://localhost:9716/PersonService.svc/DeleteRole";
req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "application/xml; charset=utf-8";
req.Timeout = 30000;
req.Headers.Add("SOAPAction", url);
req.Accept = "application/xml";
var xmlDoc = new XmlDocument { XmlResolver = null };
xmlDoc.Load(Server.MapPath("AssignRole.xml"));
string sXml = xmlDoc.InnerXml;
req.ContentLength = sXml.Length;
var sw = new StreamWriter(req.GetRequestStream());
sw.Write(sXml);
sw.Close();

res = (HttpWebResponse)req.GetResponse();
Stream responseStream = res.GetResponseStream();
var streamReader = new StreamReader(responseStream);

//Read the response into an xml document
var soapResonseXmlDocument = new XmlDocument();
soapResonseXmlDocument.LoadXml(streamReader.ReadToEnd());
lblMessage.Text = soapResonseXmlDocument.InnerXml;
Ramya singam 20-Feb-13 4:36am View    
what bindings we have to set for client. i have given bindings only in service web.config file and hosted that service in IIS. i did not set any bindings in client.

Regards,
Ramya.
Ramya singam 8-Feb-13 2:39am View    
Oh..I have solved myself...any way thank you
Ramya singam 8-Feb-13 1:59am View    
i have fixed the above issue by retuning string xml from service.but i have another problem while converting xmlstring into dataset, the dataset retuns null..

i don't know why it is retuning null.please help me

i am sharing my service method code and consuming code...

DataSet dsBuildSQL = new DataSet();
StringBuilder sbSQL;
StringWriter swSQL;
string XMLformat;

sbSQL = new StringBuilder();
swSQL = new StringWriter(sbSQL);
dsBuildSQL.Merge(DTtemp, true, MissingSchemaAction.AddWithKey);
dsBuildSQL.Tables[0].TableName = "Table";
foreach (DataColumn col in dsBuildSQL.Tables[0].Columns)
{
col.ColumnMapping = MappingType.Attribute;
}
dsBuildSQL.WriteXml(swSQL, XmlWriteMode.IgnoreSchema);
XMLformat = sbSQL.ToString();
return XMLformat;

//.Net application code

StringReader xmlReader = new StringReader(soapResonseXmlDocument.InnerXml);
DataSet ds = new DataSet();
ds.ReadXml(xmlReader);
gvView.DataSource = ds.Tables[0];
gvView.DataBind();
Ramya singam 7-Feb-13 7:51am View    
This is my code...

HttpWebRequest req = null;
HttpWebResponse res = null;
try
{
const string url = "http://localhost:4567/PersonServiceImpl.svc/auth";
req = (HttpWebRequest) WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "application/xml; charset=utf-8";
req.Timeout = 30000;
req.Headers.Add("SOAPAction", url);

var xmlDoc = new XmlDocument {XmlResolver = null};
xmlDoc.Load(Server.MapPath("PostData.xml"));
string sXml = xmlDoc.InnerXml;
req.ContentLength = sXml.Length;
var sw = new StreamWriter(req.GetRequestStream());
sw.Write(sXml);
sw.Close();

res = (HttpWebResponse) req.GetResponse(); //I got Error here
Stream responseStream = res.GetResponseStream();
var streamReader = new StreamReader(responseStream);

//Read the response into an xml document
var soapResonseXmlDocument = new XmlDocument();
soapResonseXmlDocument.LoadXml(streamReader.ReadToEnd());

//return only the xml representing the response details (inner request)
TextBox1.Text = soapResonseXmlDocument.InnerXml;
//Response.Write(soapResonseXMLDocument.InnerXml);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}