SOAP服务响应为空

时间:2013-01-20 17:15:19

标签: c# wcf soap

我没有从Web服务获得任何返回响应,正在接收输入消息XML。

尝试获取并返回符合集成标准的自定义XML,这就是我使用S.S.C.Message作为参数的原因。

using System.ServiceModel.Channels;

[ServiceContract(Namespace = "urn:hl7-org:v3")]
public interface IHL7v3
{
    [OperationContract(Name = "PRPA_IN201301UV02", Action = "urn:hl7-org:v3:PRPA_IN201301UV02")]
    Message PIXManager_PRPA_IN201301UV02(Message input);
}

public class PIXService : IHL7v3
{
    public Message PIXManager_PRPA_IN201301UV02(Message input)
    {
         // this code is being reached and executing fine
         return Message.CreateMessage(MessageVersion.Soap12, "Op", "Content"); // will be replaced by an actual XML text
    }
}

服务设置代码:

        Uri baseAddress = new Uri("http://192.168.2.120:31002/HL7Service");
        ServiceHost selfHost = new ServiceHost(typeof(PIXService), baseAddress);

        selfHost.Description.Name = "PIXManager";
        selfHost.Description.Namespace = "urn:hl7-org:v3";

        try
        {
            System.ServiceModel.Channels.Binding binder = new WSHttpBinding(SecurityMode.None);

            binder.Name = "PIXManager_Binding_Soap12";
            selfHost.AddServiceEndpoint(
                typeof(IHL7v3),
                binder,
                "PIX");

            ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
            smb.HttpGetEnabled = true;
            Console.WriteLine(smb.HttpGetUrl);
            selfHost.Description.Behaviors.Add(smb);
            selfHost.AddServiceEndpoint(
              ServiceMetadataBehavior.MexContractName,
              MetadataExchangeBindings.CreateMexHttpBinding(),
              "mex"
            );

            selfHost.Open();

想法为什么?

修改: 添加了ReplyAction,仍然没有回复

[OperationContract(Name = "PRPA_IN201301UV02", Action = "urn:hl7-org:v3:PRPA_IN201301UV02", ReplyAction = "urn:hl7-org:v3:MCCI_IN000002UV01")]
// ..
return Message.CreateMessage(MessageVersion.Soap12, "urn:hl7-org:v3:MCCI_IN000002UV01", "Something");

2 个答案:

答案 0 :(得分:1)

MessageVersion更改为MessageVersion.Soap12WSAddressing10

return Message.CreateMessage(MessageVersion.Soap12WSAddressing10, "Op", "Content");

答案 1 :(得分:0)

您的操作的ReplyAction被设置为一个值(我不记得确切的是哪个,但它是默认值),并且您正在创建具有Action属性的响应消息Op。尝试在ReplyAction中设置OperationContract属性,并在创建响应消息时使用相同的值。