WEB Service problem

Status
Not open for further replies.

rickytmp

Joined
Feb 25, 2010
Messages
14
Reaction score
0
I used WEB Service to get data from our CDM system but the WEB Service founction is not work, I found if commen out the following stament on Main_MF_ws_DoIt.aspx manually, then every thing is OK. I think the problem is from the XmlHelper, Any idea ?

private string getRootElementValue(string xml)
{
if (!String.IsNullOrEmpty(xml))
{
XmlDocument xmlDocument = new XmlDocument();
// xmlDocument.LoadXml(XmlHelper.SanitizeXmlString(xml));
XPathNavigator rootNavigator = xmlDocument.CreateNavigator();
XPathNodeIterator rootIterator = rootNavigator.SelectChildren(XPathNodeType.Element);
if (rootIterator.MoveNext()) return rootIterator.Current.InnerXml;
}

return xml;
}

Errors_WebServicesInteraction.log :

-------------------------------------
2011-12-23 16:24:10.956
System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
at System.Net.HttpWebRequest.GetResponse()
at ASP.main_mf_ws_doit_aspx.Page_Load(Object sender, EventArgs e) in c:\Documents and Settings\All Users\Application Data\3CX\Data\Http\Interface\ivr\WEBtest_Debug_35\Main_MF_ws_DoIt.aspx:line 96

Ricky
 
Hi Ricky,

You're right. We have fixed that bug, but haven't release a new version with the fix yet.

If you comment out that line, the error will go away but you will not have the desired behavior. The XML will not be loaded into the document object.

This is the code that should be being generated for that part:

Code:
  private bool isLegalXmlChar(int character)
  {
    return
    (
       character == 0x9 /* == '\t' == 9   */          ||
       character == 0xA /* == '\n' == 10  */          ||
       character == 0xD /* == '\r' == 13  */          ||
      (character >= 0x20 && character <= 0xD7FF) ||
      (character >= 0xE000 && character <= 0xFFFD) ||
      (character >= 0x10000 && character <= 0x10FFFF)
    );
  }
  
  private string sanitizeXmlString(string xml)
  {
    if (xml == null) return String.Empty;
    
    StringBuilder buffer = new StringBuilder(xml.Length);
    foreach (char c in xml)
    {
      if (isLegalXmlChar(c)) buffer.Append(c);
    }
    return buffer.ToString();
  }
  
  private string getRootElementValue(string xml)
  {
    if (!String.IsNullOrEmpty(xml))
    {
      XmlDocument xmlDocument = new XmlDocument();
      xmlDocument.LoadXml(sanitizeXmlString(xml));
      
      XPathNavigator rootNavigator = xmlDocument.CreateNavigator();
      XPathNodeIterator rootIterator = rootNavigator.SelectChildren(XPathNodeType.Element);
      if (rootIterator.MoveNext()) return rootIterator.Current.InnerXml;
    }
    
    return xml;
  }

You would have to change the getRootElementValue function with that code after building your project. That will be generated that way on the new VAD version that will be released soon.

Another option could be using an External Code Execution, and query your web service into a .NET library. That way you don't need to change the output after each build.
 
Hi VAD_Support,

The WEB Service worked fine after replace the getRootElementValue with the code you provide, Thanks. But I don't want to replace the getRootElementValue codes every time I make change of the VAD program, any idea when the new version VAD will come out.

Ricky
 
Hi VAD_Support,

I also found the WEB Service function will not work if the WEB Service in service side return nothing (VOID), is't normal ?

Ricky
 
Hi Ricky,

I can't give you a certain date of availability of the new VAD. We're working on many new features and will be releasing as soon as we can.

Meanwhile you have the option to replace that code or use an External Code Execution component where you call the web service from a .NET library.

In regards to the problem with the empty return value, we'll test it and fix it if we have a bug. Thanks for your feedback!

Regards,
 
Hi VAD_Support,

Thanks for your reply, hope the new version come out soon.

ricky
 
For now, you could hit the web service from a code component, javascript or .net, and then check the result that come back on your own.
 
Status
Not open for further replies.

Forum statistics

Threads
112,320
Messages
591,873
Members
165,466
Latest member
EMMEPICASA