function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
New_DeveloperNew_Developer 

Error with POST request

Hi,

Iam trying to implement webservices where i need to post the data from salesforce to external syatem and i wrote an apex class with POST request and i get the below error

The message with To '' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher.  Check that the sender and receiver's EndpointAddresses agree".

What does the error mean??

Thanks. Any help is appreciated.
ushrestha1.3892956293936023E12ushrestha1.3892956293936023E12
Hey there,

You just need to verify that your endpoint is correct. For some reason, the code is not being able to find the valid endpoint hence, it is not being able to POST the information. 

I suggest, if you like to see if your POST message is working or not, you could POST information into a test endpoint just to check and then finally put your required endpoint to make the magic happen.

Test endpoint URL: http://requestb.in/
Create a Request Bin Here and grab that url and put it as your endpoint and add it to your remote site settings and run your POST request. Then go back to this URL and see if it posted the information that you sent or not.


Hope that helped!

New_DeveloperNew_Developer
Thanks Shrestha. Iam sure my end point url is correct. Because i tested in SOPA UI and it worked. The end point url where the WSDL file is defined only has SOAP12 binding. It doesnot have SOAP1.1 address. Do you think that might be the reason.

Thanks
ushrestha1.3892956293936023E12ushrestha1.3892956293936023E12
Could you send the code that you have.
New_DeveloperNew_Developer
Here is my code

@Future(callout=true)
global static void sendCommunication(Integer ChildNumber, String CommType, Integer ClientID) {

HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();

req.setEndpoint('https://xxx.xx');
req.setMethod('POST');

String username = test';
String password = 'test';

Blob headerValue = Blob.valueOf(username + '' + password);
String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization', authorizationHeader);
req.setTimeout(100000);
req.setHeader('Content-Type',  'application/soap+xml; charset=utf-8');
req.setCompressed(false);

String reqBody = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/" xmlns:plan="http://schemas.datacontract.org/2004/07/">'
   +'<soap:Header/>'+
   '<soap:Body>'+
      '<tem:AddCommunicationItem>'+
        '<tem:lstCommunicationItems>'+
            '<plan:CommunicationItem>'+
                        '<plan:CommunicationType>CommType</plan:CommunicationType>'+
                  '<plan:Description>Testing123</plan:Description>'+
                        '<plan:SCNumber>ChildNumber</plan:SCNumber>'+
               '<plan:SPNumber>ClientID</plan:SPNumber>'+
            '</plan:CommunicationItem>'+
         '</tem:lstCommunicationItems>'+
       '</tem:AddCommunicationItem>'+
   '</soap:Body>'+
'</soap:Envelope>';

req.setBody(reqBody);


try {
    res = http.send(req);
} catch(System.CalloutException e) {
    System.debug('Callout error: '+ e);
}
System.debug(res.getBody());

}

Thanks
ushrestha1.3892956293936023E12ushrestha1.3892956293936023E12
Hi there,

Could you try 2 things;
1. comment out the code;
req.setCompressed(false);
2.  If that does not work then try changing BASIC to Basic: String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);


Let me know where you stand?
New_DeveloperNew_Developer
sorry, both did not work. I read somewhere that if the client and server bindings doesnot match, it throws that type of error. So doesn't it matter for the POST request  if the wsdl file has soap12 action rather than soap action??
ushrestha1.3892956293936023E12ushrestha1.3892956293936023E12
I think it would.
New_DeveloperNew_Developer
So you think the WSDL file must and should have the SOAP 1.1 binding for it to work?? I just need this confirmation so that i can go ahead and ask the client to make the SOAP1.1 available.

Thanks
ushrestha1.3892956293936023E12ushrestha1.3892956293936023E12
I do not know for sure if that will solve your problem, sorry! But for testing if that would work or not you could try.