如何从 BizTalk 2010 使用 WCF 服务
我有一个需要从 BizTalk 编排使用的 Web 服务。 我已经定义了在 BizTalk 中使用的消息架构,它们看起来像
<?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>
在 WCF 服务中,我定义了一些方法,
public ProviderResponse Provide(ProviderRequest providerRequest) {...}
其中 ProviderRequest
的定义如下:
[DataContract(Namespace = "http://www.myapp.com/schemas/IntegrationApplication-instance")]
public class ProviderRequest
{
[DataMember]
public Header Header { get; set; }
[DataMember]
public Parameter[] Parameters { get; set; }
}
当我创建发送端口并尝试发送 ProviderRequest 消息时,它会失败不同的错误。
使用与 BizTalk 项目中定义的相同架构的 WCF 服务的最佳方法是什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好的选择是运行服务的实例,然后“添加生成的项目”->从 Visual Studio 中“使用 WCF 服务”。
这将生成您的服务消息 XSD 和端口类型,并且是执行您尝试执行的操作的低摩擦方式。
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)