gautam_reddyc
asked on
Web service to Upload XML string to DB : gets error
I have a web service that accepts the xml string and uploads to the database..
[WebMethod]
public void Service(string XML)
{
try
{
using (DBDataContext db = new DBDataContext())
{
db.ImportXML(XElement.Pars e(XML));
}
}
catch (Exception err)
{
throw err;
}
}
iam getting the below error
HTTP Transport error javax.xml.soap.SOAPExcepti on Error parsing envelope: (77,40) Invalid char in Text.
i know it is occurning beceause of some invalid characters in the xml string..
is there any other way to do it.. can anyone help.
also what do i need to do if i need to upload 100mb data..
[WebMethod]
public void Service(string XML)
{
try
{
using (DBDataContext db = new DBDataContext())
{
db.ImportXML(XElement.Pars
}
}
catch (Exception err)
{
throw err;
}
}
iam getting the below error
HTTP Transport error javax.xml.soap.SOAPExcepti
i know it is occurning beceause of some invalid characters in the xml string..
is there any other way to do it.. can anyone help.
also what do i need to do if i need to upload 100mb data..
Line 77, character 40 would be were I would start.
At a guess, you have a < or a >.
At a guess, you have a < or a >.
ASKER
the special characters are # and &..
ASKER
we are on the web service side.. we have no control of what is being sent as input.. how do we parse it
replace xml special chars (like < by &gt;)
If it is a real soap service, then you reject it. It isn't valid XML and that's a requirement.
Can you show the node with the bad chars?
# doesn't ring any bells as far as I know.
& => &
Unless you have something like ...
{ and you want that as the 6 characters, rather than { it represents.
In that case ...
&#123; should be used.
Again, it isn't your concern normally as this is bad data.
Can you show the node with the bad chars?
# doesn't ring any bells as far as I know.
& => &
Unless you have something like ...
{ and you want that as the 6 characters, rather than { it represents.
In that case ...
&#123; should be used.
Again, it isn't your concern normally as this is bad data.
ASKER
it is in the comments tag
<COMMENT>Item #1089 building </COMMENT>.. there are bunch of comments tag..
how to replace all.. any idea?
<COMMENT>Item #1089 building </COMMENT>.. there are bunch of comments tag..
how to replace all.. any idea?
ASKER
i know this is a bad data.. but we need to parse the entire xml string. identify all the special characters and replace them with good data..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Works like a charm.. thanks..buddy
Woo Hoo!
in general, you might want to encode your xml string before sending it to ws