交货失败原因SalesForce出站消息

时间:2017-03-22 05:09:18

标签: salesforce

我有运行Outbound Message的工作流程:

Endpoint URL    http://testservices.com/Pixel/Send

   Fields to Send:
  AffiliateData__c AffiliateID__c EmailIdLead_ID__c

  Send Session ID : not secelted
  

我不使用Endpoint WSDL。它是好的还是我应该恭维它   回归状态到saleforce?

我的服务发送了一些像素,然后将“true”或“false”作为字符串返回。

出站邮件收到错误

Delivery Failure Reason : org.xml.sax.SAXException: Bad envelope tag: string

我需要返回什么,出站消息不会出错?或者我必须实现wsdl?

1 个答案:

答案 0 :(得分:0)

saleforse outbound massadge希望在发送格式为xml(soapenv:Envelope)的消息后获得响应。

在您的功能结束时,您需要添加此

        [Route("Send")]
        [HttpPost]
        [HttpGet]
        [WebMethod]
        [SoapDocumentMethod]
        public HttpResponseMessage Send(HttpRequestMessage request)
        {
            //you code


     //at the end add this
     XmlDocument soapEnvelop = new XmlDocument();
     soapEnvelop.LoadXml(@"<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""><soapenv:Body><notifications xmlns=""http://soap.sforce.com/2005/09/outbound""> <Ack>true</Ack></notifications></soapenv:Body></soapenv:Envelope>");

                return new HttpResponseMessage()
                 {
                     RequestMessage = Request,
                     Content = new XmlContent(soapEnvelop)
                 };

返回类型的类

public class XmlContent : HttpContent
    {
        private readonly MemoryStream _Stream = new MemoryStream();

        public XmlContent(XmlDocument document)
        {
            document.Save(_Stream);
            _Stream.Position = 0;
            Headers.ContentType = new MediaTypeHeaderValue("application/xml");
        }

        protected override Task SerializeToStreamAsync(Stream stream, System.Net.TransportContext context)
        {
            _Stream.CopyTo(stream);
            var tcs = new TaskCompletionSource<object>();
            tcs.SetResult(null);
            return tcs.Task;
        }

        protected override bool TryComputeLength(out long length)
        {
            length = _Stream.Length;
            return true;
        }

        protected override void Dispose(bool disposing)
        {
            if (_Stream != null)
                _Stream.Dispose();
        }
    }