Hi actually im facing a problem in parsing my soap response... my application is getting crashed...im trying to parse the following xml content,
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ImportIncomingSMSResponse xmlns="http://www.atom8itsolutions.com/">
<ImportIncomingSMSResult>string</ImportIncomingSMSResult>
</ImportIncomingSMSResponse>
</soap:Body>
</soap:Envelope>
im using csendonfragement for parsing, but my application crashes in the line
reader->ParseL(fss, KToBeParsed);
for ur reference ill post my code below,
TBuf8<900> SMSText;
TBuf<20> inputtext1;
_LIT(KTxt2,"success");
inputtext1.Copy(KTxt2);
TBuf8<150> Text;
SMSText.Copy(_L("<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Body><ImportIncomingSMSResponse xmlns='http://www.atom8itsolutions.com/'><ImportIncomingSMSResult>"));
SMSText.Append( inputtext1);
Text.Copy(_L("</ImportIncomingSMSResult></ImportIncomingSMSResponse></soap:Body></soap:Envelope>"));
SMSText.Append(Text);
HBufC* buf16 = HBufC::NewLC(SMSText.Length());
buf16->Des().Copy(SMSText);
//CleanupStack::PopAndDestory(buf16);
// create new XML reader and push it to the cleanupstack
CSenXmlReader* reader = CSenXmlReader::NewL();
CleanupStack::PushL(reader);
//create a CSenDomFragment
CSenDomFragment* pBase = CSenDomFragment::NewL();
CleanupStack::PushL(pBase);
//the XML document to be parsed
_LIT(KToBeParsed, "buf16");
// TBuf8<160> SMSText;
// SMSText.Copy(_L("<messages><message><from>some number</from><content>some content</content></message><message><from>some number</from><content>some content</content></message></messages>"));
//_LIT(KToBeParsed, "SMSText");
//open a filesession
RFs fss;
User::LeaveIfError(fss.Connect());
CleanupClosePushL(fss);
//must set the content handler
reader->SetContentHandler(*pBase);
// and the reader
pBase->SetReader(*reader);
//do the parsing
reader->ParseL(fss, KToBeParsed);
//after the parsing, get the elements:
RPointerArray<CSenElement>& array = pBase->AsElement().ElementsL();
//start the listing of the elements, first level is 1
ListNodesL(array,1);
CleanupStack::PopAndDestroy(3); // pBase, fss, reader
// return retVal;
}
// The listing of the elements is done in ListNodesL function:
void CSmsHandler :: ListNodesL(RPointerArray <CSenElement>& aArray,
int aLevel)
{
_LIT(KNewLine, "\n");
_LIT(KNoContent,"NO CONTENT");
_LIT(KDepthFormatString, "lev%d: ");
int j=0;
TBuf<150> pNumber;
TBuf<150> pMessage;
TInt size = aArray.Count();
for(TInt i=0; i<size; i++)
{
//get an element
CSenElement* pElement = aArray[i];
TBool hasActualContent = EFalse;
if( pElement->HasContent() )
{
//get the content of the element
TPtrC8 content = pElement->Content();
//to a HBufC, notice "LC"
HBufC *pContent = SenXmlUtils::ToUnicodeLC(content);
//print current depth (“level”)
//trim possible whitespace characters
pContent->Des().Trim();
//if there is content after the trimming
if( pContent->Length() > 0)
{
hasActualContent = ETrue;
// aConsole.Printf(*pContent);
RDebug::Print(*pContent);
if(j==0)
{
//_LIT(KTxt1,*pContent);
pNumber.Copy(*pContent);
j++;
}
else
{
// _LIT(Msg,*pContent);
//TBuf<150> pMessage;
pMessage.Copy(*pContent);
j++;
}
}
//destroy pContent
CleanupStack::PopAndDestroy(pContent);
}
if( !hasActualContent)
{
// aConsole.Printf(KNoContent);
}
//get the first child
CSenElement* child = pElement->Child(1);
RDebug::Print( _L("RDebug Hello") );
//check if element has childs
if( child )
{
//get the child elements
RPointerArray<CSenElement>& tree = pElement->ElementsL();
//list child elements by a recursive call
ListNodesL(tree, ++aLevel);
}
aLevel--;
if (j>1 && j<3)
{
this->SendSmsL(pNumber,pMessage);
j=0;
}
else if(j>=3)
{
break;
}
}
// this->SendL(pNumber,pMessage);
} //for loop ends
can any one tell me a reason y my application crashes....waiting for ur replies

waiting for ur replies
Reply With Quote




