Sunday, August 8, 2010

Info: Network Stream Length is not available at Server to read buffer from Client

In general, CLIENT writes the array of bytes or buffer and SERVER reads this buffer, but the problem is, lets say CLIENT writes X length of Array of bytes but as Network stream does not support length property therefore SERVER has no idea that how many bytes are written by CLIENT, therefore at server level its quite difficult to initialize the buffer to read. So, the best approach I think is to read data accurately without data loss , it to Read data in chunks till the end to Stream is reached in this way we can ensure the full data read also can keep the memory usage flat.

CODE SAMPLE :

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;


namespace TCPServer
{
class Program
{
static void Main(string[] args)
{
try
{
IPAddress ipAd = IPAddress.Parse("192.168.1.7");
// use local m/c IP address, and
// use the same in the client

// Initializes the Listener
TcpListener myList = new TcpListener(ipAd, 8002);

// Start Listeneting at the specified port
myList.Start();
Console.WriteLine("The server is running at port 8002...Waiting for a connection.....");

TcpClient cl = myList.AcceptTcpClient();
Console.WriteLine("Connection accepted");

Stream ns = cl.GetStream();
byte[] b = Utilities.ReadFully(ns, 0);

Console.WriteLine("Recieved...");
TRGRequest tTRGRequest = (TRGRequest)Utilities.Deserialize(b);

#region Send Ack

ASCIIEncoding asen = new ASCIIEncoding();
byte[] ack = asen.GetBytes("The string was recieved by the server.");
ns.Write(ack, 0, ack.Length);
Console.WriteLine("\nSent Acknowledgement");

#endregion

cl.Close();
ns.Close();
myList.Stop();
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine("Error..... " + e.StackTrace);
}
}
}


public class Utilities
{
public static object Deserialize(byte[] bytes)
{
BinaryFormatter bFormatter = new BinaryFormatter();
using (MemoryStream strm = new MemoryStream())
{
strm.Write(bytes, 0, bytes.Length);
strm.Seek(0, SeekOrigin.Begin);
return (object)bFormatter.Deserialize(strm);
}
}



///
/// Reads data from a stream until the end is reached. The
/// data is returned as a byte array. An IOException is
/// thrown if any of the underlying IO calls fail.
///

/// The stream to read data from
/// The initial buffer length
public static byte[] ReadFully(Stream stream, int initialLength)
{
// If we've been passed an unhelpful initial length, just
// use 32K.
if (initialLength < 1)
{
initialLength = 32768;
}

byte[] buffer = new byte[initialLength];
int read = 0;

int chunk;
while ((chunk = stream.Read(buffer, read, buffer.Length - read)) > 0)
{
read = read + chunk;

// If we've reached the end of our buffer, check to see if there's
// any more information
if (read == buffer.Length)
{
int nextByte = stream.ReadByte();

// End of stream? If so, we're done
if (nextByte == -1)
{
return buffer;
}

// Nope. Resize the buffer, put in the byte we've just
// read, and continue
byte[] newBuffer = new byte[buffer.Length * 2];
Array.Copy(buffer, newBuffer, buffer.Length);
newBuffer[read] = (byte)nextByte;
buffer = newBuffer;
read = read + 1;
}
else
{
//return buffer;
// Buffer is now too big. Shrink it.
byte[] ret = new byte[read];
Array.Copy(buffer, ret, read);
return ret;
}

}
byte[] ret1 = new byte[read];
Array.Copy(buffer, ret1, read);
return ret1;
}
}
}

Info : TCP/IP- Network Stream understanding in Client Server Architecture

Well, I am enroute for writing cutom adapter for BizTalk i.e. TCPAdapter, as I dont have much knowledge of this protocol, and very I am not going to attain full knowledge on TCP as I always leave some scope of learning of future.
So, let me share my partial knowledge with you guys , please correct me if I am wrong and feel free to extend this post with your outstanding knowledge.
Earlier when I created some .NET applications which interacts with each other by using .NET remoting, ok let me expand a bit, 2 different applications that means atleast in 2 different Appdomains (if they are same Appdomains we dont need remoting we just need to reference assmbly and invokes its method or whatever crap we want to do..) and if we want to these 2 appliations communicate with each other there comes .NET remoting (Now again we can use web services or HTTP to make them communicate but for now lets park them aside, we will keep our focus on TCP) then we used to do marshalling (MBR or MBV).
Something like, Client application makes call to Proxy (again, Tansparent proxy which is something like superset of real proxy) and this proxy and then the object is formatted by suitable formatter (in case of TCP , its Binary formatter and in case of HTTP its SOAP Formatter ) and then formatted object is pushed to channel and then at server application this formmated object is re-formatted back to the original shape nad then get access to remote object or application or whatever.
Dont get confused by formatted object, its basically a serialized object or better Binary serialized object or more specifically an array of bytes, these bytes passes through channel and then at server application Deserialized back to the original object from the array of bytes. Great RIGHT??
I guess NO, in this case you need share your class definitions or object model with client as we were doing since ages while doing web services development as we share WSDL files with client application.

When I was very new to BizTalk, I was very afraid of Streams and BizTalk uses streams as max a possible at adapters , at pipelines, at Maps etc etc.. therefore I was afraid of BizTalk too.
But later on I came to know BizTalk is design to work with any message formats whether it is XML or flat files or binary or anything you can can think of. So, with no doubt Streams was the only choice to work with BizTalk.
So, I thought of creating Client - Server applications which will communicate via TCP and share messages in form of streams.
So in short, SERVER should be able to LISTEN at one port, CLIENT will connect to SERVER then CLIENT creates an object and Serializes this object in bytes and then CLIENT will Send these bytes to SERVER which receives these bytes and then Deserializes it back to the object.
Note: In these extending the functionalities as I am formatting and reformatting objects i.e. Serialization and Deserialization explicitly, Earlier it was done automatically before by the applications at the boundaries of communication channel.

Rather then, sharing the hell lot of crap story lets go ahead with the code.
(when connecion is established between CLIENT and SERVER, resources are allocated for communication which are generally termed as Channel, and in this code Network streams is used to read and write bytes at both client and server, Code itself speaks everything and its working but not that beautiful) , If you people have any doubts or correction please let me know

CLIENT CODE:

using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Net.Sockets;
using System.Runtime.Serialization.Formatters.Binary;


namespace TCPClient
{
class Program
{
static void Main(string[] args)
{
try
{
TcpClient tcpclnt = new TcpClient();
Console.WriteLine("Connecting.....");

tcpclnt.Connect("192.168.1.7", 8002);
// use the ipaddress as in the server program

Console.WriteLine("Connected");

TRGRequest req = new TRGRequest();
req.Packet = "10255PatientTransferrdkhanycb3urhg55p3khu1br#633557240738841151TRGIP1ADTA01388falsetrue1200221falseRJRCLEBAE1CSCUBedZMQCKZ2009-02-05T12:47:332009-02-05T12:47:33G2009-02-05T12:47:33TBQQCDZR395473151RHQCDZR395473151RHGMC ID numberMPKGMC224210852RLNATGP IDnumberMPKNATGP224210852RLNLVCUIAMNLVCUIAMOFKAMTJ227166764OFKAMTJ227166764WYUBB2953CNQSZPALMNKZH3342INUQLXXMHVXU791P1408EVU9100J2883TJY648582865SHH1513G2962DEHPTOVKGJGPTOVKGJGNTFTUYNTFTUYPublicitycodeProtectionindicatorDJTOPXCXUOQJJINNBOVDJZE2009-02-05T12:47:33DfalseZX2009-02-05T12:47:33ZTQBDFNFOPDZY
PPUZVG8265K6561HGYEW
EHDZD806C9683HNStrueI4642Q1141
TXUJS1111U4413ZTXUJS1111U4413ZCC_IDTYPASNBR123RVYMRLRIBNOT FACILNVK4763I6240KAIUUB2009-02-05T12:47:33G1444L7512MVYT
PPUZVG8265K6561HGYEW
PPUZVG8265K6561HGYEW
HNSI4642Q1141HNSI4642Q1141HNStrueI4642Q1141HNStrueI4642Q1141HNStrueHNStrue
IUUB2009-02-05T12:47:33G1444L7512MVYT
PPUZVG8265K6561HGYEW
PPUZVG8265K6561HGYEW
HNSI4642Q1141HNSI4642Q1141HNStrueI4642Q1141HNStrueI4642Q1141HNStrueHNStrue
VUDE880923590D1585Q3802AIW5205RABRS9268W1559TFHVNT9783G9871EIXQJMGPTOVKGJGPTOVKGJGNTFTUYNTFTUYPublicitycodeProtectionindicatorEXWBSJBWJJDJTO
YUT6391QQAVZWTBWZVZWTBWZRUQSQSEX6115SZVZWTBWZVZWTBWZGO
";
req.Metadata = new Metadata();
req.Metadata.AppStackVersion = "2.630.0.0";

Stream stm = tcpclnt.GetStream();

byte[] ba = Utilies.Serialize(req);

Console.WriteLine("Transmitting.....");

stm.Write(ba, 0, ba.Length);

byte[] bb = new byte[100];
int k = stm.Read(bb, 0, 100);

for (int i = 0; i < bformatter =" new" ms =" new" ipad =" IPAddress.Parse(" mylist =" new" cl =" myList.AcceptTcpClient();" ns =" cl.GetStream();" b =" Utilities.ReadFully(ns," ttrgrequest =" (TRGRequest)Utilities.Deserialize(b);" asen =" new" ack =" asen.GetBytes(" bformatter =" new" strm =" new">
/// Reads data from a stream until the end is reached. The
/// data is returned as a byte array. An IOException is
/// thrown if any of the underlying IO calls fail.
///
/// The stream to read data from
/// The initial buffer length
public static byte[] ReadFully(Stream stream, int initialLength)
{
// If we've been passed an unhelpful initial length, just
// use 32K.
if (initialLength < initiallength =" 32768;" buffer =" new" read =" 0;" chunk =" stream.Read(buffer,"> 0)
{
read = read + chunk;

// If we've reached the end of our buffer, check to see if there's
// any more information
if (read == buffer.Length)
{
int nextByte = stream.ReadByte();

// End of stream? If so, we're done
if (nextByte == -1)
{
return buffer;
}

// Nope. Resize the buffer, put in the byte we've just
// read, and continue
byte[] newBuffer = new byte[buffer.Length * 2];
Array.Copy(buffer, newBuffer, buffer.Length);
newBuffer[read] = (byte)nextByte;
buffer = newBuffer;
read = read + 1;
}
else
{
//return buffer;
// Buffer is now too big. Shrink it.
byte[] ret = new byte[read];
Array.Copy(buffer, ret, read);
return ret;
}

}
byte[] ret1 = new byte[read];
Array.Copy(buffer, ret1, read);
return ret1;
}
}
}


OBJECT MODEL of TRGRequest :
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
// Runtime Version:2.0.50727.42
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//

//------------------------------------------------------------------------------

using System.Xml.Serialization;
using System.Runtime.Serialization;

//
// This source code was auto-generated by xsd, Version=2.0.50727.42.
//


///
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
public partial class TRGRequest {

private string packetField;

private Metadata metadataField;

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string Packet {
get {
return this.packetField;
}
set {
this.packetField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute("Metadata", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public Metadata Metadata {
get {
return this.metadataField;
}
set {
this.metadataField = value;
}
}
}

///
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class Metadata {

private string sendingOrgIDField;

private string sendingSystemField;

private string receivingOrgIDField;

private string receivingSystemField;

private string domainField;

private string messageTypeField;

private string messageIDField;

private string iXMLVersionField;

private string appStackVersionField;

private string machineAddrField;

private string serviceNameField;

private string sessionIDField;

private string replayFlagField;

private string messageSystemField;

private string originalProductionTypeField;

private string originalProductionNameField;

private string currentProductionNameField;

private string finalProductionTypeField;

private string finalProductionNameField;

private string directionField;

private string currentFormatField;

private string statusField;

private string errorCodeField;

private string errorStringField;

private string dateCreatedField;

private string contentTypeField;

private string refToMessageIDField;

private string custom1Field;

private string custom2Field;

private string custom3Field;

private string mSATextField;

private string patientIDField;

private string patientPrimaryFacilityField;

private string patientPrimaryCareProviderField;

private string patientClassField;

private string assignedPatientLocationField;

private string preAdmitNumberField;

private string visitIDField;

private string placerOrderNumberField;

private string placerGroupNumberField;

private string orderStatusField;

private string enteredByField;

private string orderingProviderField;

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string SendingOrgID {
get {
return this.sendingOrgIDField;
}
set {
this.sendingOrgIDField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string SendingSystem {
get {
return this.sendingSystemField;
}
set {
this.sendingSystemField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string ReceivingOrgID {
get {
return this.receivingOrgIDField;
}
set {
this.receivingOrgIDField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string ReceivingSystem {
get {
return this.receivingSystemField;
}
set {
this.receivingSystemField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string Domain {
get {
return this.domainField;
}
set {
this.domainField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string MessageType {
get {
return this.messageTypeField;
}
set {
this.messageTypeField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string MessageID {
get {
return this.messageIDField;
}
set {
this.messageIDField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string iXMLVersion {
get {
return this.iXMLVersionField;
}
set {
this.iXMLVersionField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string AppStackVersion {
get {
return this.appStackVersionField;
}
set {
this.appStackVersionField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string MachineAddr {
get {
return this.machineAddrField;
}
set {
this.machineAddrField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string ServiceName {
get {
return this.serviceNameField;
}
set {
this.serviceNameField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string SessionID {
get {
return this.sessionIDField;
}
set {
this.sessionIDField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string ReplayFlag {
get {
return this.replayFlagField;
}
set {
this.replayFlagField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string MessageSystem {
get {
return this.messageSystemField;
}
set {
this.messageSystemField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string OriginalProductionType {
get {
return this.originalProductionTypeField;
}
set {
this.originalProductionTypeField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string OriginalProductionName {
get {
return this.originalProductionNameField;
}
set {
this.originalProductionNameField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string CurrentProductionName {
get {
return this.currentProductionNameField;
}
set {
this.currentProductionNameField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string FinalProductionType {
get {
return this.finalProductionTypeField;
}
set {
this.finalProductionTypeField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string FinalProductionName {
get {
return this.finalProductionNameField;
}
set {
this.finalProductionNameField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string Direction {
get {
return this.directionField;
}
set {
this.directionField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string CurrentFormat {
get {
return this.currentFormatField;
}
set {
this.currentFormatField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string Status {
get {
return this.statusField;
}
set {
this.statusField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string ErrorCode {
get {
return this.errorCodeField;
}
set {
this.errorCodeField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string ErrorString {
get {
return this.errorStringField;
}
set {
this.errorStringField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string DateCreated {
get {
return this.dateCreatedField;
}
set {
this.dateCreatedField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string ContentType {
get {
return this.contentTypeField;
}
set {
this.contentTypeField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string RefToMessageID {
get {
return this.refToMessageIDField;
}
set {
this.refToMessageIDField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string Custom1 {
get {
return this.custom1Field;
}
set {
this.custom1Field = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string Custom2 {
get {
return this.custom2Field;
}
set {
this.custom2Field = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string Custom3 {
get {
return this.custom3Field;
}
set {
this.custom3Field = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string MSAText {
get {
return this.mSATextField;
}
set {
this.mSATextField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string PatientID {
get {
return this.patientIDField;
}
set {
this.patientIDField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string PatientPrimaryFacility {
get {
return this.patientPrimaryFacilityField;
}
set {
this.patientPrimaryFacilityField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string PatientPrimaryCareProvider {
get {
return this.patientPrimaryCareProviderField;
}
set {
this.patientPrimaryCareProviderField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string PatientClass {
get {
return this.patientClassField;
}
set {
this.patientClassField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string AssignedPatientLocation {
get {
return this.assignedPatientLocationField;
}
set {
this.assignedPatientLocationField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string PreAdmitNumber {
get {
return this.preAdmitNumberField;
}
set {
this.preAdmitNumberField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string VisitID {
get {
return this.visitIDField;
}
set {
this.visitIDField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string PlacerOrderNumber {
get {
return this.placerOrderNumberField;
}
set {
this.placerOrderNumberField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string PlacerGroupNumber {
get {
return this.placerGroupNumberField;
}
set {
this.placerGroupNumberField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string OrderStatus {
get {
return this.orderStatusField;
}
set {
this.orderStatusField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string EnteredBy {
get {
return this.enteredByField;
}
set {
this.enteredByField = value;
}
}

///
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string OrderingProvider {
get {
return this.orderingProviderField;
}
set {
this.orderingProviderField = value;
}
}
}

Thursday, August 5, 2010

Error details: The published message could not be routed because no subscribers were found.

Error details: The published message could not be routed because no subscribers were found. This error occurs if the subscribing orchestration or send port has not been enlisted, or if some of the message properties necessary for subscription evaluation have not been promoted. Please use the Biztalk Administration console to troubleshoot this failure.

Reason : As simple as, BizTalk engine is not able to find subscriptions for the incoming message.
under the hood : while publishing the message in BizTalkMsgDB [SPOOL] table. Biztalk engine executes many stored procedures, but the point in focus here are (1). bts_InsertProperty [this SP is executed for each context property of Message] (2).bts_FindSubscriptions [pass batch id as parameter and queries Subscription, ConvoySetInstance and many predicates table and gets subscription Id] (3).bts_InsertMessage [subscrition Id is passed as parameter, commits message in Spool table and call various SPs] , (4).int_EvaluateSuscription [passed subscription Id as parameter and then message reference is inserted into respective queue].

So, as far as entry(row) is there in Subscription table it may passed to the next level and may we will not get this error.
Resolution : 1. Check the Orchestration or SendPort is Enlisted which is going the message
2. If the input message is XML then use XMLReceivePipeline, as this pipeline contains XMLDisassembler components which populates MessageType context property which is used for routing xml messages.

Error : Finding the document specification by message type failed. Verify the schema deployed properly.

I am a BizTalk but recently got interviewed from Microsoft, for support role and they are looking people for BizTalk Administration role. finally failed in 3rd round or interview.
Since then I started learning BizTalk from administration .

Recently I was building an application which polls a SQL Table at regular time interval, and get records from the table and feed these request to BizTalk Engine, where BizTalk Orchestration is subscribed to these MessageTypes and carry out rest of the processing.
Being a Developer, I have always used the simplest way for deploying an application, "Right Click to solution and select Deploy" as expected everything goes fine all artifacts got deployed in default Application "BizTalk Application 1".
Then I decided to do this to deploy solution in different "Application", I did necessary configuration and fired a message. Then I got the error as mentioned as title of this post.
Reason is very clear "The schemas was deployed in BizTalk Application 1", then I moved the neceassry schemas in new application" then it worked.
From the Default application, select the artifacts -> right click -> then Select move to application.