WCF服务-接收没有包装正文节点的消息

时间:2018-08-03 15:55:03

标签: wcf

我们遇到一个问题,即客户端向我们发送不包含包装节点的肥皂信封。因此,在分派.svc时,请求变量不包含所有XML,而仅包含第一个节点。

这是CreateCase消息的界面:

@Controller
@RequestMapping ("/")
public class DemoController {
   @RequestMapping (value = "demo", method = RequestMethod.GET)
   public String printWelcome (ModelMap model) {
      model.addAttribute ("message", "Hello world!");
      return "hello";
}

@Scheduled (fixedRate = 5000)
public void ScheduledFixedRate () {
    System.out.println ("I will execute after evey 5 seconds");
}

这是CreateCaseRequest类定义:

 [System.ServiceModel.OperationContractAttribute(ReplyAction = "*", Action = "urn:oasis:names:tc:legalxml-courtfiling:wsdl:WebServicesProfile-Definitions-4.0/CourtRecordMDEPort/CreateCaseRequest")]
 [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
 CreateCaseResponse CreateCase(CreateCaseRequest request);

这是CreateCase的.svc实现:

[System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.MessageContractAttribute(IsWrapped = false)]
    public partial class CreateCaseResponse
    {
        [System.ServiceModel.MessageBodyMemberAttribute(Namespace = "urn:oasis:names:tc:legalxml-courtfiling:schema:xsd:MessageReceiptMessage-4.0", Order = 0)]
        public XElement MessageReceiptMessage;

        public CreateCaseResponse()
        {
        }

        public CreateCaseResponse(XElement MessageReceiptMessage)
        {
            this.MessageReceiptMessage = MessageReceiptMessage;
        }
    }

如果肥皂包膜具有包装器节点,则一切正常。但是,客户端没有向我们发送包装器节点,因此我需要以某种方式告诉WCF它是否在那里,以便事情能够正确处理。

这是我收到的肥皂信封:

public CreateCaseResponse CreateCase(CreateCaseRequest request)
        {
            logger.Log("Create Case Received");
            request.CreateCaseMessage.Save("c:/test.xml");
        }

这是生成的XML文件-意味着在服务请求中。CreateCaseMessage并不表示根节点,而是下一个节点。

<s:Body>
<CreateCaseMessage xmlns="urn:tyler:ecf:extensions:CreateCaseMessage" xmlns:tyler="urn:tyler:ecf:extensions:Common" xmlns:nc="http://niem.gov/niem/niem-core/2.0" xmlns:j="http://niem.gov/niem/domains/jxdm/4.0" xmlns:s="http://niem.gov/niem/structures/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecf="urn:oasis:names:tc:legalxml-courtfiling:schema:xsd:CommonTypes-4.0">
<nc:DocumentFiledDate>
<nc:DateTime>2018-08-03T15:47:45.0Z</nc:DateTime>
</nc:DocumentFiledDate>
<nc:DocumentIdentification>
<nc:IdentificationID>75885</nc:IdentificationID>
<nc:IdentificationCategoryText>ENVELOPEID</nc:IdentificationCategoryText>
</nc:DocumentIdentification>
...

如何更改服务行为以正确接受未包装的消息,以便request.CreateCaseMessage表示<?xml version="1.0" encoding="utf-8"?> <DocumentFiledDate xmlns="http://niem.gov/niem/niem-core/2.0"> <DateTime>2018-08-03T15:47:45.0Z</DateTime> </DocumentFiledDate> 节点?

0 个答案:

没有答案