I have a web service that I need to consume from BizTalk orchestration. I've defined message schemas which I use in BizTalk, they look like
<?xml version="1.0" encoding="utf-16"?>
<xs:schema
xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
xmlns="http://www.myapp.com/schemas/IntegrationApplication-instance"
xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
xmlns:ns0="https://DTIB.PropertySchema"
elementFormDefault="qualified"
targetNamespace="http://www.myapp.com/schemas/IntegrationApplication-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation=".\CommonTypes.xsd" />
<xs:element name="ProviderRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="Header" type="HeaderType" />
<xs:element name="Parameters" type="ParametersType" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
In WCF service I have methods defined like
public ProviderResponse Provide(ProviderRequest providerRequest) {...}
where ProviderRequest
is defined like
[DataContract(Namespace = "http://www.myapp.com/schemas/IntegrationApplication-instance")]
public class ProviderRequest
{
[DataMember]
public Header Header { get; set; }
[DataMember]
public Parameter[] Parameters { get; set; }
}
When I create send port and try to send a ProviderRequest message it fails with different errors.
What's the best method to consume a WCF service which uses the same schemas as defined in BizTalk project?
Your best bet is to run an instance of your service and then "Add Generated Items" -> "Consume WCF Service" from within Visual Studio.
This will generate your service message XSDs and port types and is a low-friction way of doing what you are trying to do.