Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Call a webservice with an “object” parameter from orchestration
- This topic has 12 replies, 1 voice, and was last updated 9 years, 3 months ago by
community-content.
-
AuthorPosts
-
-
August 25, 2008 at 9:58 AM #20494
Hi,
I am working on a project where I need to call a remote WS from an orchestration.
I started out by adding a web reference to my orchestration but received the error “Failed to add Web Refernece”. I did some research about this issue but didn’t find a solution to the problem.
I then took another route by manually creating the proxy class via the wsdl.exe tool which in short gave me the following method signature:
public object Foo(ref string vReturn, object vXML)
{
object[] results = this.Invoke(“Method”, new object[] {
(object)vReturn,
vXML});
vReturn = results[1].ToString();
return ((object)(results[0]));
}
}
Next I created a custom pipeline component to construct the multipart message required for the Web Service call
// private component method
IBaseMessage CreateMessage(Stream s, IBaseMessageFactory msgFactory, IBaseMessageContext context)
{
IBaseMessage msg = msgFactory.CreateMessage();
IBaseMessagePart part = msgFactory.CreateMessagePart();
part.Data = s;
msg.Context = context;
//vReturn
IBaseMessagePart vReturn = msgFactory.CreateMessagePart();
byte[] firstPart =
System.Text.Encoding.UTF8.GetBytes(string.Format(“<string>{0}</string>”, “”));
vReturn.Data = new MemoryStream(firstPart);
vReturn.Charset = “utf-8”;
vReturn.ContentType = “text/xml”;
msg.AddPart(“vReturn”, vReturn, false);
//vXML
msg.AddPart(“vXML”, part, true);
return msg;
}
I then configured the solicit-response SOAP sendport to use the GACed proxy class.
However I’m now getting the following error:
“Error Description: Failed to serialize the message part “vXML” into the type “Object” using namespace “”. Please ensure that the message part stream is created properly.”
Any help to take me further is appreciated!
Regards,
//Ershad
-
August 25, 2008 at 10:13 AM #20495
Since you are on R2, I would recommend using the WCF-BasicHttp adapter instead of the SOAP adapter. This adapter has a schema generation wizard which works much better than adding a web reference. Here is a walkthrough http://msdn.microsoft.com/en-us/library/bb246019.aspx. Also, the WCF adapters will greatly improve your life over the SOAP adapter 🙂
-
August 25, 2008 at 10:52 PM #20505
Thanks Russell for a great response! I’ll try it out and return with an update!
//Ershad
-
August 28, 2008 at 12:28 AM #20519
Hi Russell,
I got the add web reference to work with the WCF schema generation wizard. The schema generated for the web service request looks as followed:
<xs:schema . . .>
<xs:element name=“ImportJobPC_XML“>
<xs:complexType>
<xs:sequence>
<xs:element minOccurs=“0“ maxOccurs=“1“ name=“vReturn“ />
<xs:element minOccurs=“0“ maxOccurs=“1“ name=“vJobXML“ />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I need to set the vRetur element and vJobXML in my orchestration and pass it to the web service. Currently this is implemented with VB6 code calling the web service. In the VB6 code the vReturn parameter is set to a string value and the vJobXml is an xml passed as string.
I want to achieve the same thing in BizTalk.
What I get into BizTalk is an XML-document which corresponds to the vJobXML and the vReturn element is just a constant string.
I’ve tried to create a map in my orchestration but mapping over element of type string to an anyType element doesn’t seem to work.
I appreciate any suggestions?
Regards,
//Ershad
-
August 28, 2008 at 12:45 AM #20520
-
August 28, 2008 at 5:40 AM #20522
Hi Ershad,
You have a couple of options:
1. In the map, use a Mass Copy functoid to copy the any node into another XML document.
2. Use the xpath() function to pull out the XML you want. Example:
jobXmlMessage = xpath(wsResponse, “/*[local-name()=’ImportJobPC_XML’]/*[local-name()=’vJobXML’]”);
That would need to go in a message asignment shape.
3. Configure the WCF adapter to auto extract this XML for you. On the Messages tab of the adapter config, you can enter an XPath expression to run on the web service response. You could just put in the XPath above, and then in your orchestration you would receive just the vJobXML. Cool huh?
I don’t know if that XPath is right, so you will need to test. Here is the best XPath testing tool I have found: http://www.biztalkgurus.com/blogs/biztalksyn/archive/2007/11/25/dansharp-xmlviewer.aspx
Let me know how it goes!
-
August 28, 2008 at 6:14 AM #20523
Hi Russell,
Options 1 and 2 are definately interesting. But I don’t think option 3 is. The message that comes in to the orchestration comes in via the FILE adapter.
I’m not sure if i’ve picked the best solution for this problem but what I’m doing is that I recunstruct the message in a receive pipeline to a multiprt message just as described in my first post. I then need to map this recontructed message to the web service request in my orchestration.
I’m now trying to call a orchestration facade (external .NET assembly) to pull the body parts out form the incoming message and map them to the web service request message.
Sure thing i’ll return with an update:-)
Thanks a lot for your posts!!!
//Ershad
-
August 28, 2008 at 7:24 AM #20524
Oh, for the options I posted, I was talking about extracting XML from the web service response received via the WCF adapter. Option 3 is a useful technique for getting web service responses, but not possible when receiving data from a file adapter. However, options 1 & 2 are applicable with the file adapter.
-
August 30, 2008 at 2:32 AM #20540
I spoke with a former colleague of mine about this issue yesterday. He mentioned that if the “add reference” in a BizTalk project fails that should give a warning signal. I explained to him how I used wsdl.exe tool to generate a proxy and that the proxy expects an “object” as parameters when invoking the web service. He quickly responded that the problem is that BizTalk can’t just serialize the “object” as the type is unknown. With that said this practically leaves me with the options to convince the exposer of the web service to rewrite the interface to “typed method signature” or rewrite the service.
//Ershad
-
August 30, 2008 at 5:17 AM #20541
Have you tried calling the web service with the WCF-BasicHttp adapter? You shouldn’t get a serialization error using this adapter because it doesn’t have to serialize anything. You are just sending an XML message. It is already serialized. If you use the SOAP adapter and a proxy class, suspect the proxy class is taking the XML from BizTalk, loading it into an object variable, then trying to serialize it to send it over the wire. Hence your receive a serialization error.
That said, object parameters are not the best contract design, so it wouldn’t be a bad idea to get them to type it. If you really need to accept any XML, then I guess they are a good choice, but usually that is not the case.
-
September 1, 2008 at 12:05 AM #20548
Hi Russell,
I’m still working on this issue. My primarily intention is to get WCF to work. If not I’ll somehow will work for trying to change the Webservice interface. Anyway I’ll return with an update!
// Ershad
-
September 1, 2008 at 11:46 PM #20551
Hi Russell,
I’ve set up the walkthrough but I receive the following error on the call to the WS
<faultcode xmlns:a=”http://schemas.microsoft.com/ws/2005/05/addressing/none“>a:ActionNotSupported</faultcode><faultstring xml:lang=”sv-SE“>The message with Action ‘<BtsActionMapping xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema”> <Operation Name=”Submit” Action=”http://Microsoft.Samples.BizTalk.WCF.BasicHttpSendAdapter.BasicHttpWcfServiceConsuming/IOrderProcess/Submit” /> </BtsActionMapping>’ cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</faultstring></s:Fault>My Soap action header in the send port is set to this
<BtsActionMapping xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema“>
<Operation Name=”Submit” Action=”http://Microsoft.Samples.BizTalk.WCF.BasicHttpSendAdapter.BasicHttpWcfServiceConsuming/IOrderProcess/Submit” />
</BtsActionMapping>Any ideas on hos I can troubleshoot this?
//Ershad
-
September 2, 2008 at 7:11 AM #20555
I read on in an another forum thread that when BtsActionMapping is used the WCF adapter tries to match the operation name with an action defined in the BtsActionMapping, and if it can’t find the Operation context property in the BTS message, it sets the whole BtsActionMapping as the action on the outgoing WCF message.
And since no orchestrations are used the Operation context property (that comes with the default binding file) is not set.
The solution is to set the action of the send port directly to http://Microsoft.Samples.BizTalk.WCF.BasicHttpSendAdapter.BasicHttpWcfServiceConsuming/IOrderProcess/Submit
//Ershad
-
-
-
-
-
-
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.