Home Page › Forums › BizTalk 2004 – BizTalk 2010 › BizTalk 2006 R2 WCF-basicHttp adapter configuration – Getting message in service – with null value
- This topic has 6 replies, 1 voice, and was last updated 9 years, 3 months ago by
community-content.
-
AuthorPosts
-
-
January 15, 2009 at 7:42 AM #21511
Hi.
Something bad happens with my message which sholud get out of BizTalk trough WCF-basicHttp adapter to my WCF service.
I have a WCF service which needs as a paramter some message, which comes from BTS, but everytime that message arrives as null.
After looking in Administration Console – I saw that the message is normal with all it’s context, it also does not failes inside my pipline (custom components), but still is coming as null.
Where else can be a problem? We suspect that this problem happens in the adapter (no another components between adapter and a service)
Any ideas?
-
January 16, 2009 at 11:18 AM #21515
I am having the same issue (WCF Contract Mismatch with BizTalk 2006 R2 EDI XML Schema). Rather than start a new thread, I’ll just jump in here.
I’m kind of new to BizTalk and to WCF and am having what I believe to be a small issue with deserializing a message in a WCF service. What I have is a very basic sample application just trying to get the concept working:
A BizTalk 2006 R2 orchestration is up and running that will receive an X12 270 Eligibility Request message (schema from the MicrosoftEdiXSDTemplates.exe file that comes with BizTalk 2006 R2), sends the request to a trading partner via a Send/Receive port, and sends the X12 271 Eligibility Response (once received from the trading partner) to a send port.
When the Send Port is configured to simply write the X12 271 response to an XML file on disk, the whole thing works great. However, what I really way is to send it to a WCF service. So, I created the below, very simple, WCF service hosted in a console application (only added reference is System.ServiceModel). When the process is executed, the web service does get called, but the “response” (message) parameter on the “WriteResponse” method is always null (although if I check the message in the BizTalk admin tool, it looks good), and I get the error detailed at the bottom of this post. What am I missing?
*******************
Service.cs
*******************
[ServiceContract(Namespace=”http://myuri.org”),
XmlSerializerFormat(Style = OperationFormatStyle.Document, Use = OperationFormatUse.Literal)]public interface IResponseToSQL
{
[OperationContract(IsOneWay = true, Action = “http://myuri.org/IResponseToSQL/WriteResponse”)]
void WriteResponse(MyNamespace.X12_00401_271 response);}public class ResponseToSQL : IResponseToSQL
{
#region IResponseToSQL Memberspublic void WriteResponse(MyNamespace.X12_00401_271 response)
{
Console.WriteLine(“WriteResponse method called…”);if (response == null)
Console.WriteLine(“The response message is null.”);
else
Console.WriteLine(“The response message is not null. Save the response to SQL…”);
}
}*******************
Program.cs
*******************
class Program
{
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(“ResponseToSQL service is up and running with the following endpoints:”);using (ServiceHost host = new ServiceHost(typeof(EligibilityLookup.WCF.Host.ResponseToSQL), new Uri(“http://localhost:8000/ResponseToSqlService”)))
{
// HTTP
host.AddServiceEndpoint(typeof(EligibilityLookup.WCF.Host.IResponseToSQL), new BasicHttpBinding(),
“basic”);// WS Http
host.AddServiceEndpoint(typeof(EligibilityLookup.WCF.Host.IResponseToSQL), new WSHttpBinding(),
“ws”);// Named Pipes
host.AddServiceEndpoint(typeof(EligibilityLookup.WCF.Host.IResponseToSQL), new NetNamedPipeBinding(),
“net.pipe://localhost/ResponseToSqlService/pipe”);// TCP/IP
host.AddServiceEndpoint(typeof(EligibilityLookup.WCF.Host.IResponseToSQL), new NetTcpBinding(),
“net.tcp://localhost:8082/ResponseToSqlService/tcp”);host.Open();
foreach (System.ServiceModel.Description.ServiceEndpoint endPoint in host.Description.Endpoints)
Console.WriteLine(endPoint.Address.ToString());Console.WriteLine(“Press a key to terminate host.”);
Console.ReadLine();
}
}
}I also generated a class file using XSD.exe to get the X12_00401_271 class. I generated it off the same XSD schema I used in the BizTalk orchestration to define the response message (which, again was plucked out of the MicrosoftEdiXSDTemplates.exe file that comes with BizTalk 2006 R2). The command I used was:
xsd.exe X12_00401_271.xsd /c /namespace:MyNamespace
*******************
BizTalk 2006 R2 Send Port Configuration
*******************
–Main Property Page–
Type: WCF-BasicHttp
Send Handler: BizTalkServerApplication
Send pipeline: PassThruTransmit
(rest of settings are default)–Type Configuration (WCF-BasicHttp)–
Endpoint Address:http://machinename:8000/ResponseToSqlService/basic
SOAP Action Header Action: http://is.org/IResponseToSQL/WriteResponse
(rest of settings are default)*******************
Resulting Error (from Windows Event Viewer)
*******************
Event Type: Error
Event Source: BizTalk Server 2006
Event Category: BizTalk Server 2006
Event ID: 5754
Date: 1/16/2009
Time: 1:08:50 PM
User: N/A
Computer: VIRTUALBIZTALK
Description:
A message sent to adapter “WCF-BasicHttp” on send port “WcfResponseSendPort” with URI “http://machinename:8000/ResponseToSqlService/basic” is suspended.
Error details: System.ServiceModel.CommunicationException: The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.Server stack trace:
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndRequest(IAsyncResult result)Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.ServiceModel.Channels.IRequestChannel.EndRequest(IAsyncResult result)
at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.RequestCallback(IAsyncResult result)
MessageId: {7FD75D76-04C8-4136-987D-F674C4321611}
InstanceID: {A6B69FCF-D16A-47A2-8CB1-A6F17327E433}For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Thanks in advance!
-
January 16, 2009 at 12:24 PM #21516
Note:
If I change the X12_00401_271 type of the parameter to type “System.ServiceModel.Channels.Message”, I can see the contents just fine.
-
January 17, 2009 at 5:17 AM #21518
…but I should add that that doesn’t help me or Zx7R here in the slightest. The message passed needs to be deserialized to the type that we are expecting. Someone here has got to know this…
How do we get our messages to deserialize properly?
-
January 18, 2009 at 8:10 AM #21519
I’m now accepting the entire message as the WCF method parameter and am manually serializing only the Body ( message.WriteBody(xmlWriter) ). WHen I examine the output XML file, I’ve got an extra XML node in the content that is preventing me from deserializing again:
<s:Body xmlns:s=”http://schemas.xmlsoap.org/soap/envelope/”>
<My XML content…>
</s:Body>
If I manually strip that section out of the XML file, it deserializes just fine. I strongly suspect the deserialization the WCF service handles automatically is having very same issue.
Zx7R,
Are you getting the same results as I am with your application?
-
January 19, 2009 at 1:00 AM #21523
Not yet, didn’t touch that code for couple of days.
Now I return to it, we’ll see. [:)]
-
January 20, 2009 at 1:28 PM #21538
Well, for now it seems I will have to work around this issue by converting the message body to a string and manually deserializing it. This works fine and doesn’t add much code, I just don’t think this is the right way to handle it.
My Code (to deserialize to type “X12_00401_271”):
// Convert the message body to a string
StringBuilder stringBuilder = new StringBuilder();
using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(stringBuilder))
{
message.WriteBody(writer);
writer.Flush();
}// Remove the pieces of the string that are causing a deserialization problem (investigate later)
string content = stringBuilder.ToString();
content = content.Replace(“<s:Body xmlns:s=\”http://schemas.xmlsoap.org/soap/envelope/\”>”, string.Empty);
content = content.Replace(“</s:Body>”, string.Empty);try
{
// Attempt to deserialize the string taken from the message body to an X12_00401_271 object
X12_00401_271 responseMessage = null;using (StringReader stringReader = new StringReader(content))
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(X12_00401_271));
responseMessage = (X12_00401_271)xmlSerializer.Deserialize(stringReader);
}// TODO: Do stuff with your object
}
Catch(Exception e)
{
// TODO: Handle exception
}
-
-
-
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.