Thanks for your response.
Ive tried with and without the String->Byte[]->String conversion and tried
using XMLTextWriter to build the string but this still causes problems.
This is my aspx page:-
<%@ Page Language="C#" Debug="true" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.Text.RegularExpressions" %>
<%@ import Namespace="System.Xml" %>
<%@ import Namespace="System.Net" %>
<%@ import Namespace="XMLMethods" %>
<%@ import Namespace="SMSservices" %>
<%@ import Namespace="Authenticate" %>
<script runat="server">
// Insert page code here
SMSAuthentication oSec = new SMSAuthentication();
SMSServices oClient = new SMSServices();
XMLMethods xm = new XMLMethods();
string Username = "test";
string Password = "test";
string messageStr = "";
string messageStatus = "";
string returnKey = "";
string strXML = "";
string Key;
string sXMLRet = "Key";
string proxy = "http://hmt-pxy-2.test.com:8080";
protected void Page_Load(Object Src, EventArgs E)
{
//Authenticate with proxy using default or my login info
if(!"".Equals(proxy))
{
WebProxy proxyObject = new WebProxy(proxy);
// Disable proxy use when the host is local.
proxyObject.BypassProxyOnLocal = true;
//Set proxy Credentials to authenticate on server
//proxyObject.Credentials =
System.Net.CredentialCache.DefaultCredentials;
proxyObject.Credentials = new NetworkCredential("test",
"test", "test");
// HTTP requests use this proxy information.
GlobalProxySelection.Select = proxyObject;
}
// Create Message XML string
messageStr = xm.BuildSendXML("1","Snippets please","44773423432");
try {
//strXML = messageStr
Encoding ascii = Encoding.ASCII;
Byte[] encodedBytes = ascii.GetBytes(messageStr);
strXML = ascii.GetString(encodedBytes);
}
catch(Exception e) {
sXMLRet = "<p>ERROR: XML String parse: Please contact
test</p><p>"+e+"</p>";
}
//'Login to obtain valid key
try {
oSec.clientLogin(Username,Password,ref Key);
}
catch(Exception e) {
sXMLRet = "<p>ERROR: Login Failed: Please contact
test</p><p>"+e+"</p>";
}
if (Key != null)
{
try {
returnKey = oClient.sendSMSsender(strXML, "44773423432", Key);
try {
sXMLRet =
oClient.getBatchMessageStatus(messageStatus,Key);
} catch(Exception e){
sXMLRet = "ERROR: Get Message Status Error<br>please
contact test<BR>"+e;
}
}
catch(Exception e){
sXMLRet = "ERROR: Send Message Error<br>please contact
test<br><br>"+e;
}
}
}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<!-- Insert content here -->
<p>
<%=returnKey%>
</p>
<p>
<%=strXML%>
</p>
<p>
<%=sXMLRet%>
</p>
</form>
</body>
</html>
and this is the class that I use to build the XML:-
// XMLMethods.cs
//
namespace XMLMethods {
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using System.IO;
using System;
using System.Xml;
/// <summary>
/// Summary description for XMLMethods.
/// </summary>
public class XMLMethods {
/// <summary>
/// Creates a new instance of XMLMethods
/// </summary>
public XMLMethods() {
}
public string BuildSendXML(String id,String message, String
destination) {
StringWriter sw = new StringWriter();
XmlTextWriter SMSwriter = new XmlTextWriter(sw);
try
{
SMSwriter.Formatting = Formatting.Indented;
SMSwriter.Indentation= 6;
SMSwriter.Namespaces = false;
//SMSwriter.WriteStartDocument(); //outputs beginning xml
tag
SMSwriter.WriteStartElement("", "SMSBatchFile", "");
SMSwriter.WriteStartElement("", "SMSMessage", "");
SMSwriter.WriteStartElement("", "MessageID", "");
SMSwriter.WriteString(id);
SMSwriter.WriteEndElement();
SMSwriter.WriteStartElement("", "MessageText", "");
SMSwriter.WriteString(message);
SMSwriter.WriteEndElement();
SMSwriter.WriteStartElement("", "Destination", "");
SMSwriter.WriteString(destination);
SMSwriter.WriteEndElement();
SMSwriter.WriteEndElement(); //close smsmessage
SMSwriter.WriteEndElement(); //close smsbatchfile
SMSwriter.Flush();
sw.Close();
}
catch(Exception e)
{
//return "Exception: {0}"+ e;
Console.WriteLine("Exception: {0}", e.ToString());
}
finally
{
if (SMSwriter != null)
{
SMSwriter.Close();
}
}
return sw.ToString();
}
public static void Main(string[] args){
//Test BuildSendXML() method
//XMLMethods xm = new XMLMethods();
//String outTxt = xm.BuildSendXML("7","Tickets please","02342375");
//Console.WriteLine(outTxt);
}
}
}
> Hi,
>
[quoted text clipped - 56 lines]
> >>
> >> Has anyone encountered this?
Marvin Smit - 27 Oct 2005 14:12 GMT
Hi,
thanks for the additional info;
before diving in deeper, i have a question;
Is there any reason for you "not to use a generated proxy"?
Marvin Smit
>Thanks for your response.
>
[quoted text clipped - 273 lines]
>> >>
>> >> Has anyone encountered this?
Deepak - 27 Oct 2005 23:16 GMT
Hello
I had a similar problem in one of my web services. it is a problem of the
data in the xml. Errors of this type are hard to debug. I did a replace after
a I receive a response from the web service just to remove any unrecognizable
characters.
Not an efficient solution but works.
Another thing, can you load your request string into an xml document properly?
Thanks
Deepak
> Hi,
>
[quoted text clipped - 272 lines]
> >> >> SMSservices.SMSServices.sendSMSsender(String Messages, String Sender, String
> >> >> Key) at ASP.Authenticate_aspx.Page_Load(Object Src, EventArgs E) in