Dismiss Notice
We would like to remind you that we’re updating our login process for all 3CX forums whereby you will be able to login with the same credentials you use for the Partner or Customer Portal. Click here to read more.

WEB Service problem

Discussion in 'CRM / Helpdesk / App Integration' started by rickytmp, Dec 23, 2011.

Thread Status:
Not open for further replies.
  1. rickytmp

    Joined:
    Oct 6, 2011
    Messages:
    13
    Likes Received:
    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
     
  2. VAD_Support

    VAD_Support Active Member

    Joined:
    Aug 6, 2009
    Messages:
    690
    Likes Received:
    0
    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.
     
  3. rickytmp

    Joined:
    Oct 6, 2011
    Messages:
    13
    Likes Received:
    0
    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
     
  4. rickytmp

    Joined:
    Oct 6, 2011
    Messages:
    13
    Likes Received:
    0
    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
     
  5. VAD_Support

    VAD_Support Active Member

    Joined:
    Aug 6, 2009
    Messages:
    690
    Likes Received:
    0
    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,
     
  6. rickytmp

    Joined:
    Oct 6, 2011
    Messages:
    13
    Likes Received:
    0
    Hi VAD_Support,

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

    ricky
     
  7. SWSDEV

    SWSDEV Member

    Joined:
    Feb 23, 2008
    Messages:
    256
    Likes Received:
    0
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Thread Status:
Not open for further replies.