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.

其他提示

Quite interesting question, a scenario that might happen to others.

Here are some suggestions.

Most common case: You need to consume a service and want to use those messages - Use hugh's suggestion "Add generated item..."

Less common case: You have already created a schema that a service also uses (the same) - Use hugh's suggestion "Add generated item..." - Remove the schema that is a duplicate, either your own or from the created

Not so common case: You want to consume two services that uses the same schema - Use hugh's suggestion "Add generated item..." - Remove the schema that is a duplicate from one of the generated

Have never happened to me case: You have already created a schema that a service also uses (NOT the same, but same root name and name space) - There is nothing to do, this will not work (out of the box)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top