You need to sign in to do that
Don't have an account?
Premature end of file error when sending outbound message
I have an integration utilizing Salesforce's "Outbound Messaging" functionality. When rule's criteria is met, a message is sent to an endpoint (a Java servlet) configured in my application. This endpoint takes the incoming SOAP request from Salesforce, processes its body and performs the desired action in my application. The HTTP response from my application is a SOAP document with a "notificationsResponse" element. However, as far as Salesforce is concerned, the outbound message workflow is not complete. In the "Outbound Messaging Delivery Status" screen in Salesforce, my message shows up as still being in the queue with a delivery failure reason of "org.xml.sax.SAXParseException: Premature end of file."
Looking for information on the outbound messaging functionality, I've come across the outbound messaging document, the outbound messaging WSDL document as well as various blogs talking about similar issues, but I haven't been able to come up with a workable solution. Some questions, then:
- Should my servlet be sending the SOAP document immediately as its HTTP response, or should it send an asynchronous SOAP response (i.e., through an entirely new HTTP request)?
- Is the notificationsResponse a red herring? Am I receiving the SAXParseException because of another problem?
- Should I also be sending some kind of response to the original SOAP request to immediately tell Salesforce that I got the request and everything's OK? I've tried two different responses for the doPost() method in my endpoint servlet: (a) a void method, so no response is being sent, and (b) a method that returns a string representing the notificationsResponse object.
you're on the right track.
(a) what does SUCCESS_RESPONSE look like ?
(b) you almost certainly need to close or at least flush your OutputStreamWriter.
All Answers
Your servlet should send a http/soap response (as a response to the inbound http request) as per the schema in the WSDL when you've processed the message. Best place to start is with a wire capture of the request/response from your servlet. (soapscope, wireshark, etc)
Thanks for the response, Simon. So you're saying I'm doing it correctly by returning my SOAP document as the immediate response from my servlet's doPost() method? For example:
Or should I be sending an entirely separate, new SOAP request back to Salesforce with the notificationsResponse object? Because what I pasted into the code area above is what I'm currently doing, and I'm receiving the exception.
you're on the right track.
(a) what does SUCCESS_RESPONSE look like ?
(b) you almost certainly need to close or at least flush your OutputStreamWriter.
You're probably right about the OutputStreamWriter; I'll try that and see. The value of SUCCESS_RESPONSE is this:
You were absolutely right, Simon. I needed to flush my OutputStreamWriter, and the response was successfully sent back to Salesforce. The outbound messaging queue is once again empty!