I'm writing a series of Apex webservices that I will be accessing from a third-party application, pulling data from Contacts & related records and creating new records. I've managed the 3rd party configuration to the point that I think I'm getting to my org, but it looks like the two processes are not talking to each other well. (Can you tell I mostly work inside my org, not interacting externally..?)
The request/input is defined as follows:
{
"requestUrlTemplate": "/services/Soap/c/41.0/0DF2C000000009c/inventory_schema_retrieval/getInventorySchema",
"requestType": "POST",
"headers": {},
"requestTemplate": "{\"contactId\": \"${input.ContactId}\"}"
}
and the webservice method is defined like this:
@HttpPost webservice static InventorySchema getInventorySchema(String contactId) {
Here's the error:
{
"status": 500,
"code": "internal.server.error",
"message": "The server encountered an unexpected condition which prevented it from fulfilling the request.",
"messageParams": {},
"contextId": "d4ea9866-286f-43f0-acf5-7ee327b35bbe",
"details": [],
"errors": [
{
"status": 500,
"code": "INTERNAL_SERVER_ERROR",
"message": "REST call for action execute failed. Message:Request to backend service failed.\n<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Client</faultcode><faultstring>content-type of the request should be text/xml</faultstring></soapenv:Fault></soapenv:Body></soapenv:Envelope>\n [d4ea9866-286f-43f0-acf5-7ee327b35bbe] [d4ea9866-286f-43f0-acf5-7ee327b35bbe]",
"messageParams": {},
"details": [],
"errors": []
}
]
}
... (some time passes) ... By adding Content-Type to the request header, the error message has changed
{
"requestUrlTemplate": "/services/Soap/c/41.0/0DF2C000000009c/inventory_schema_retrieval/getInventorySchema",
"requestType": "POST",
"headers": {"Content-Type": "text/xml"},
"requestTemplate": "{\"contactId\": \"${input.ContactId}\"}"
}
resulting in
{
"status": 500,
"code": "internal.server.error",
"message": "The server encountered an unexpected condition which prevented it from fulfilling the request.",
"messageParams": {},
"contextId": "bcd46666-63a5-4995-a8d7-bb197eb9171a",
"details": [],
"errors": [
{
"status": 500,
"code": "INTERNAL_SERVER_ERROR",
"message": "REST call for action execute failed. Message:Request to backend service failed.\n<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Client</faultcode><faultstring>SOAPAction HTTP header missing</faultstring></soapenv:Fault></soapenv:Body></soapenv:Envelope>\n [bcd46666-63a5-4995-a8d7-bb197eb9171a] [bcd46666-63a5-4995-a8d7-bb197eb9171a]",
"messageParams": {},
"details": [],
"errors": []
}
]
}
Bother -- I've added the SOAPAction header, as well as Content-Type, and am now seeing 'Content is not allowed in prolog.' The headers look like this:
"headers": {"Content-Type": "text/xml",
"SOAPAction": "anything"},
[based on SOAPAction discussion missing-soap-action-header
Here is the New, Improved error:
{
"status": 500,
"code": "internal.server.error",
"message": "The server encountered an unexpected condition which prevented it from fulfilling the request.",
"messageParams": {},
"contextId": "f8aff33b-c61f-4a44-beaf-3540ae2aca0c",
"details": [],
"errors": [
{
"status": 500,
"code": "INTERNAL_SERVER_ERROR",
"message": "REST call for action execute failed. Message:Request to backend service failed.\n<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Client</faultcode><faultstring>Content is not allowed in prolog.</faultstring></soapenv:Fault></soapenv:Body></soapenv:Envelope>\n [f8aff33b-c61f-4a44-beaf-3540ae2aca0c] [f8aff33b-c61f-4a44-beaf-3540ae2aca0c]",
"messageParams": {},
"details": [],
"errors": []
}
]
}