6

Say I have a SOAP message heading for my org, kind of like a flaming meteorite:

  • I don't really know where it came from,
  • I won't be able to touch it before it arrives,
  • I can't change where it lands, just what it lands on,

All I know is that I need to handle it with a WebService method and it kinda looks like this:

<Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Body>
    <notifications>
      <ObjId>000000000000000AAA</ObjId>
      <Notification>
        <Id>04ld000000OEiP5AAL</Id>
        <sObject xsi:type="sf:Custom__c">
          <sf:Id>a00d000000QEPOjAAP</sf:Id>
        </sObject>
      </Notification>
    </notifications>
  </Body>
</Envelope>

So I eyeball the transmission above and start to write a WebService class that might fit:

global class NotificationService {

  global class Notification {
    webService String Id;
    //webService String sObject;
  }

  static webService Boolean notifications(String ObjId, List<Notification> Notification) {
    return true;
  }

}

Then I make sure the SOAP message is destined for the above web service endpoint and let the class handle one message.

I receive this error:

No operation available for request {}notifications, please check the WSDL for the service.

It appears Salesforce Web Services won't touch an inbound request without this correct. So let's pretend I can change the namespace (which I can't) and the inbound message now reads <notifications xmlns="http://soap.sforce.com/schemas/class/NotificationService"> - now the handler will start running OK, and of course encounter issue with the format.

Next I'll receive this error:

There is no public member called 'sObject' in the Apex class 'Notification'

But, alas, sObject is a reserved word. I will struggle to save a public member with that name. Any thoughts or guidance are very welcome:

1) Can I get the web service handler to ignore the namespace of the inbound message?

2) Can the handler's signature to match the inbound request, including reserved words?

  • Can I please know how to send an appropriate response from salesforce rest webservice, to notify the server that the outbound message is received ? thanks in advance BR Venkat – user18363 Apr 15 '15 at 14:51
5

While I'd be happy (and surprised!) to see an implementation using the webservice framework, I think it's impossible. The documentation keeps silence about adjusting namespaces or field names, and both are handled internally.

There is some hope though. Salesforce outbound messages are simple enough to successfully accept them with Apex REST. You could expose a method with no parameters as @HttpPost, grab the message from RestContext.request.requestBody and then parse it into DOM.

| improve this answer | |
  • Did this actually work? Generally the outbound messages won't have the Session Id in the required location to call back into the same org. Is the REST service being hosted in Sites or similar to get around this? – Daniel Ballinger Feb 26 '15 at 21:00
  • @DanielBallinger You're absolutely right, Apex REST would need to be exposed through a public Site. If you don't want to implement a proxy (e.g. on Heroku) it's likely to be the only option to accept messages without proper OAuth headers. And yes, it works (although haven't implemented for outbound messages specifically). – endrju Mar 3 '15 at 5:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.