简体   繁体   中英

Calling WCF Service with no input parameters in BizTalk Orchestration

I am trying to call an IIS hosted WCF web service that simply returns the current date from a BizTalk orchestration. There are no input parameters to this service.

Please ignore the First Receive_1 and the Last Send_1 shapes as I just used them to get started with this orchestration. My Orchestration looks like:

在此处输入图片说明

I used the "Add Generated Items..." wizard to add the generated reference to the web service in the Orchestration. My web service definition looks like:

[ServiceContract]
public interface ICalculator
{
    [OperationContract]
    DateTime GetLastExecutionDate();
}

public class CalculatorService : ICalculator
{

    public DateTime GetLastExecutionDate()
    {
        return DateTime.Now.AddMonths(-6);
    }
}

After I added the generated reference to the BizTalk project, the wizard created a set of ports and Multi Part Messages like below:

在此处输入图片说明

I have also created local messages to transport data between these calls like below:

在此处输入图片说明

Now, I have read everywhere I could that I will need to construct the InputMessage in order to call a web service with no parameters.

Some forums/website say that I need to simply created a blank ConstructMessage shape with the MessageType of dateRequest Message. While doing so the project doesn't compile and I get the following error message:

在此处输入图片说明

And the other suggested item is to do a MessageAssignment for a blank Document. So the MessageAssginment shape in my Orchestration has the following:

xDoc = new System.Xml.XmlDocument();
xDoc.LoadXml("<GetLastExecutionDate/>");
dateRequest.parameters = xDoc;

While this compiles and get's deployed, my BizTalk instance get's suspended with the following exception:

There was a failure executing the send pipeline: "Microsoft.BizTalk.DefaultPipelines.XMLTransmit, Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Source: "XML assembler" Send Port: "REDACTED_1.0.0.0_REDACTED.ExportData_WCFPort_dace989afd9cd9c5" URI: " http://localhost/COMPANYNAME/WCFService/Service.svc " Reason: This Assembler cannot retrieve a document specification using this type: "GetLastExecutionDate".

And the parameter data passed into the service is:

So my question is: How do I call a WCF Service that does not expect any input parameters.

Go to your service request message schema file from within visual studio.

Right click -> Generate Instance.

Grab the XML instance generated and replace all the double quotes with single quotes.

Then paste this into your LoadXml() in your assignment

在此处输入图片说明

You use the XMLTransmit pipeline and there could be multiple root causes for it throwing error message

"Reason: This Assembler cannot retrieve a document specification using this type: xxx"

The most likely cause is that you do not have a schema deployed matching the message you are transmitting.

But the good news is that there is no need for the XMLTransmit pipeline in this scenario. Just change the send-pipeline to PassThruTransmit and it will most likely solve at least that problem.

You probably need an XML namespace in the string used in the message assignment shape. I suggest you validate your XML string against the web service schema to make sure it makes a valid message.

You could also use xsd.exe to create .NET classes from your web service schema.

See http://msdn.microsoft.com/en-us/library/aa547985(BTS.20).aspx for a complete list of ways to contruct a message in an orchestration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM