我正处于BizTalk 2009集成的另一端,我有一个相当简单的合同,看起来像这样:
[ServiceContract(Name = "ReceiverService", Namespace = "http://services.company.org/")]
public interface IReceiverService : ILoadBalanced
{
[OperationContract]
void FinishedRouting(long applicationId);
[OperationContract]
void ResponsePending(long applicationId, string stringId, short count);
[OperationContract]
void ReportException(long applicationId, string errorMessage, string stringId);
[OperationContract]
void SaveResponse(WebResponseDto decision);
}
但是,当BizTalk组尝试使用WCF服务使用向导时,它会阻塞并提供此堆栈跟踪:
[5096] System.NullReferenceException: Object reference not set to an instance of an object.
[5096] at Microsoft.BizTalk.Adapter.Wcf.Consuming.Exporters.BindingInfoExporter.CreatePrimaryTransport(ServiceEndpoint serviceEndpoint, Boolean custom)
[5096] at Microsoft.BizTalk.Adapter.Wcf.Consuming.Exporters.BindingInfoExporter.CreateSendPort(ServiceEndpoint endpoint, Port port, Boolean custom)
[5096] at Microsoft.BizTalk.Adapter.Wcf.Consuming.Exporters.BindingInfoExporter.Export(ServiceEndpointCollection endpoints, ServiceDescriptionCollection wsdlDocuments, Boolean custom)
[5096] at Microsoft.BizTalk.Adapter.Wcf.Consuming.Consumer.CreateBindingFiles(MetadataSet metadataSet, String serviceName)
然后再来一次:
[5096] System.NullReferenceException: Object reference not set to an instance of an object.
[5096] at Microsoft.BizTalk.Adapter.Wcf.Consuming.Implementation.ClientImplementation.AddFilesToProject(String schemaNamespace)
[5096] System.NullReferenceException: Object reference not set to an instance of an object.
[5096] at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
[5096] at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
[5096] at Microsoft.BizTalk.Adapter.Wcf.Consuming.Consumer.Consume(ISynchronizeInvoke synchronizeInvoke, DTE dte, MetadataSet metadataSet, Project project, String importNamespace)
任何人都知道从哪里开始看这个?
答案 0 :(得分:1)
您能否确认可以在简单的WCF服务上使用WCF消费向导(没有基本接口,一个操作,字符串输入和字符串返回)?如果没有,可能是您的VS IDE已损坏。
FWIW void返回似乎不是问题 - BTS为void操作创建以下响应模式
<xs:element name="GetDataResponse">
<xs:complexType>
<xs:sequence />
</xs:complexType>
</xs:element>
将Contract和Base Contract接口放在不同的名称空间中也没问题。
但是,向DTO /实体添加非序列化属性时,svcutil和BizTalk WCF向导都失败了
HTH
namespace WcfService1
{
[ServiceContract(Namespace = "http://someorl.org/ns1")]
public interface IBase
{
[OperationContract]
void SomeBaseMethod(int value);
}
[ServiceContract(Namespace = "http://someorl.org/ns2")]
public interface IService1 : IBase
{
[OperationContract]
void GetData(int value);
[OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite);
// TODO: Add your service operations here
}
// Use a data contract as illustrated in the sample below to add composite types to service operations.
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";
[DataMember]
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}
[DataMember]
public string StringValue
{
get { return stringValue; }
set { stringValue = value; }
}
//[DataMember]
//public XmlDocument NonSerializable
//{
// get;
// set;
//}
}
}
答案 1 :(得分:0)
WCF客户端应用程序无法使用具有单向操作的服务合同将消息发送到您的WCF接收位置。客户端合同上的操作应使用IsOneWay = false和ReplyAction =“*”进行注释。唯一的例外是当您使用NetMsmqBinding时,在这种情况下,客户合同上的所有操作都应该是单向的。