I am trying to send an invite with sdp header attached. For that I have written a sample application.
However when I am trying to send the Invite.
iSIPClientTransaction = iSIPInviteDialogAssoc->SendInviteL(msgElements);// This function is leaving...
I am attached the code snippet. Plz help me to solve this prob.

Code:
CSIPInviteDialogAssoc* CSIPExample::CreateSIPInviteDialogAssoc()
{
	// Construct toHeader. 
	CSIPAddress* toAddress =
		CSIPAddress::DecodeL(_L8("sip:vrex@dgg"));
	CleanupStack::PushL(toAddress);
	CSIPToHeader* toHeader = CSIPToHeader::NewL(toAddress);
	CleanupStack::Pop(toAddress);
	CleanupStack::PushL(toHeader);
	// and construct CSIPInviteDialogAssoc by using
	// from- and toHeaders:
	CSIPInviteDialogAssoc* inviteDialogAssoc =
		CSIPInviteDialogAssoc::NewL(
		*iConnection,
		toHeader,
		*iProfile );
	CleanupStack::Pop(toHeader);
	return inviteDialogAssoc;
}
//MSIPProfileRegistryObserver implementation:
void CSIPExample::ProfileRegistrationStatusChanged(TUint32 aSIPProfileId)
{
	// First inform User Interface that this method is being called
	User::InfoPrint(_L("ProfileRegistrationStatusChanged"));
	// Check that the changed profile is the same we use
	if (aSIPProfileId == iProfile->Id())
	{
		// Check that registration to the server was successful
		if ( iProfile->Status() == CSIPProfile::ERegistered)
		{
			// Get a connection object from ProfileRegistry.k
			// Note: this can only be done after successful
			// registration.
			iConnection = iProfileRegistry->ConnectionL(*iProfile);

			iSIPInviteDialogAssoc =	CreateSIPInviteDialogAssoc();
			//initialize string pool, this is a MUST
			SdpCodecStringPool::OpenL();
			RStringPool pool = SdpCodecStringPool::StringPoolL();
			CSdpDocument *sdpDoc=NULL;
			sdpDoc=CSdpDocument::NewLC();
			sdpDoc->SetSessionNameL(_L8("SipSession"));
			
			TInt64 sessionId( TUint( 2890844526 ) );
			TInt64 sessionVersion( TUint( 2890842807 ) );
			TInetAddr address; 
			const TUint32 KInetAddr = INET_ADDR(172,16,0,223); 
			address.SetAddress( KInetAddr );
			CSdpOriginField* originfield = CSdpOriginField::NewL( _L8("player"), sessionId, sessionVersion, address);
			sdpDoc->SetOriginField(originfield);


			RStringF netType = pool.StringF( SdpCodecStringConstants::ENetType, SdpCodecStringPool::StringTableL() );
			RStringF addressTypeIP4 = pool.StringF( SdpCodecStringConstants::EAddressTypeIP4, SdpCodecStringPool::StringTableL() );

			_LIT8( KAddress, "172.16.0.223" );
			CSdpConnectionField* connectionfield = CSdpConnectionField::NewL( netType, addressTypeIP4, KAddress );
			CleanupStack::PushL(connectionfield);
			sdpDoc->SetConnectionField(connectionfield);
			CleanupStack::Check(connectionfield);
			CleanupStack::Pop(connectionfield);
			

			RStringF mediaVideo = pool.StringF( SdpCodecStringConstants::EMediaVideo, SdpCodecStringPool::StringTableL()); 
			RStringF protocol = pool.StringF(SdpCodecStringConstants::EProtocolRtpAvp, SdpCodecStringPool::StringTableL()); 
			CSdpMediaField* media = CSdpMediaField::NewLC(mediaVideo, 49152, protocol, _L8("96"));
			RStringF sendonlyAttr = pool.StringF( SdpCodecStringConstants:: EAttributeSendonly, SdpCodecStringPool::StringTableL() ); 
			CSdpAttributeField* attr1 = CSdpAttributeField::NewLC(sendonlyAttr, _L8("")); 
			User::LeaveIfError((media->AttributeFields()).Append(attr1)); 
			CleanupStack::Pop(); //attr1

			_LIT8( KEncodingName, "H263-2000" ); _LIT8( KClockRate, "90000" ); _LIT8( KEncodingParam, "" );
			TSdpRtpmapValue rtpmapValue( KEncodingName(), KClockRate(), KEncodingParam() ); 
			HBufC8* rtpmapBuf = rtpmapValue.EncodeL(); 
			CleanupStack::PushL(rtpmapBuf);
			RStringF rtpmapStr = pool.StringF( SdpCodecStringConstants::EAttributeRtpmap, SdpCodecStringPool::StringTableL() );
			CSdpFmtAttributeField* rtpmapAttribute = CSdpFmtAttributeField::NewLC(rtpmapStr, _L8("96"), *rtpmapBuf);
			User::LeaveIfError(media->FormatAttributeFields().Append (rtpmapAttribute)); 
			CleanupStack::Pop(); // rtpmapAttribute 
			CleanupStack::PopAndDestroy(); // rtpmapBuf
			User::LeaveIfError(sdpDoc->MediaFields().Append(media));
			CleanupStack::Check(media);
			CleanupStack::Pop(media);


			if (sdpDoc->IsValid())
			{
				CBufStore* store = CBufStore::NewLC(1);
				RStoreWriteStream writeStream;
				TStreamId writeStreamId = writeStream.CreateL(*store);
				CleanupClosePushL(writeStream);
				sdpDoc->EncodeL(writeStream);
				MStreamBuf* buffer = writeStream.Sink();
				TInt length = buffer->SizeL();
				writeStream.Close();
				CleanupStack::Pop();

				HBufC8* sdpBuffer = HBufC8::NewLC(length);
				TPtr8 bufPtr(sdpBuffer->Des());

				RStoreReadStream readStream;
				readStream.OpenL(*store,writeStreamId); 
				CleanupClosePushL(readStream);
				readStream.ReadL(bufPtr,length);
				readStream.Close();
				CleanupStack::Pop();

				CSIPContentTypeHeader* contentType = CSIPContentTypeHeader::NewL(_L8("application"),_L8("sdp"));
				CleanupStack::PushL(contentType);
				CSIPMessageElements* msgElements = CSIPMessageElements::NewLC();

				msgElements->SetContentL(sdpBuffer,contentType);

				
				iSIPClientTransaction = iSIPInviteDialogAssoc->SendInviteL(msgElements);/* Here this function is leaving*/
				
				CleanupStack::Check(msgElements);
				CleanupStack::Pop(msgElements);
				CleanupStack::Check(contentType);
				CleanupStack::Pop(contentType);
				CleanupStack::Check(sdpBuffer);
				CleanupStack::Pop(sdpBuffer);
				CleanupStack::Check(store);
				CleanupStack::Pop(store);
				CleanupStack::Check(sdpDoc);
				SdpCodecStringPool::Close();
				CleanupStack::PopAndDestroy(sdpDoc);
				
				
			}
		}
	}
}