1

I have a scenario where I need to send JSON through a dynamic send port. For that reason I created a send pipeline with the JSON encoder with the option Remove Outer Envelope = true.

I have the pipeline associated with my dynamic port and the pipeline has both Xml assembler and Json encoder (I also tried without the xml assembler and the result was the same).

My construct shape for the request message has the following code:

varXml.LoadXml(
"<ns0:DataMigrationRequest xmlns:ns0=\"http://temp">"+
  "<ns0:DataSets>Local Products</ns0:DataSets>"+
  "<ns0:Country>Spain</ns0:Country>"+
  "</ns0:DataMigrationRequest>"
);

msgRequest = varXml;

msgRequest(WCF.SuppressMessageBodyForHttpVerbs)="POST"; 
msgRequest(WCF.TransportClientCredentialType) = "None";
msgRequest(WCF.AlgorithmSuite) = "Default";
msgRequest(WCF.SecurityMode)="Transport";
msgRequest(WCF.HttpMethodAndUrl)=@"POST"; 
msgRequest(BTS.IsDynamicSend) = true;

msgRequest(WCF.BindingType)="customBinding";
msgRequest(WCF.Action)="";
msgRequest(WCF.BindingConfiguration)=@"<binding name=""customBinding""><httpsTransport /></binding>";

msgRequest(WCF.EndpointBehaviorConfiguration) = @"
<behavior name=""customBehavior"">
    <CustomBehavior />
</behavior>";

Dynamic_Port(Microsoft.XLANGs.BaseTypes.Address) =     System.String.Format("https://localhost/temp");
Dynamic_Port(Microsoft.XLANGs.BaseTypes.TransportType)="WCF-Custom";  

Every time that I try to send a message I get the error:

Error details: System.Xml.XmlException: Data at the root level is invalid.

If I replaced the dynamic port by a static port everything works and I'm able to send the message as expected. It just doesn't work is I send as a dynamic.

For sure something is missing, anyone has any hints that could help?

Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54
Ricardo
  • 99
  • 2
  • 10
  • Which version of BizTalk? – Dijkgraaf Jul 01 '16 at 22:02
  • Also did you try it with just the XML assembler in the pipeline? If that is what is throwing the error then it is a problem with that. – Dijkgraaf Jul 01 '16 at 22:14
  • Version is BizTalk 2013 R2. Only with the XML Assembler I don't have any issues. – Ricardo Jul 02 '16 at 20:11
  • Do you have a Schema published with the namespace http: //temp and root DataMigrationRequest? The JSON Assembler does need the schema – Dijkgraaf Jul 03 '16 at 04:52
  • I see that in your construct shape you have msgRequest(WCF.SuppressMessageBodyForHttpVerbs)="POST"; which will suppress the actual body, that is payload, so when the jsonencoder tries to convert xml to json there is nothing there. Usually the message body is suppressed for GET requests. – erik Dec 23 '21 at 16:41

1 Answers1

0

I think that I figured the issue. It seems that WCF-Custom can only work with XML messages, as such, I replaced with WCF-WebHttp.

Ricardo
  • 99
  • 2
  • 10