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
juppyjuppy 

System.CalloutException: IO Exception: Unexpected end of file from server

Hi guys,

I'm trying to do a SOAP-based callout to an external webservice and am frustrated by the above error.

What makes it worse is I am unable to get anything out of the debug logs that helps. The callout looks (to me) to be correctly formed.

 

However, the receiving system (non-salesforce) is apparently not seeing my login attempt.

A question that shows my relative inexperince with webservices: how can I be sure I am doing a 'POST' and not a 'GET'?

 

Pseudo-code follows.

The references to 'Identitymanagemen' are to classes generated from wsdl that represents the other webservice.

As you can see there is nothing tricksy in my code so suggestions on a strategy for debugging that code appreciated.

 

My business sponsor is evangelising the use of sfdc in his company so a rapid response would be most welcome.

First correct answer wins a free drink at CloudForce*!

 

Many thanks in advance.

 

        Identitymanagemen.IdentityManagementServiceHttpPort SOAPMessage = new Identitymanagemen.IdentityManagementServiceHttpPort();
        SOAPMessage.endpoint_x    = SPCacheAIMMetadata.getServiceLocation();
        SOAPMessage.timeout_x        = 30000;
 
        // Set http header
        SOAPMessage.outputHttpHeaders_x = new Map<String, String>();

        string username = xxxxxx;
        string password = xxxxxx;
        Blob headerValue = Blob.valueOf(username + ':' + password);
        string authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);

        SOAPMessage.outputHttpHeaders_x.put('Authorization', authorizationHeader);

        Identitymanagemen.identityDetails thisReturnStub = new Identitymanagemen.identityDetails();

        thisReturnStub = SOAPMessage.getIdentity('test', 'test');

 

 

* I'm not going to CloudForce this year ;>) but I'll issue a raincheck

Best Answer chosen by Admin (Salesforce Developers) 
juppyjuppy

The receiving server had a firewall blocking the sf IP addresses (and just about everything else too). Persuaded them to temporarily give access and the callout worked straight away.... hope this info is useful to others in the community!

 

All Answers

dkadordkador

That usually means whatever server you're calling out to isn't responding correctly.  Possibly they're sending a Content-Length that's greater than the actual content they're sending.  Do you have control over the external webservice?

juppyjuppy

Thanks for the quick response!

No I don't have direct control over the external webservice, however as it is in another department of the client I can certainly ask for changes / debug code to be added.

I'll post an update here later on.

juppyjuppy

The receiving server had a firewall blocking the sf IP addresses (and just about everything else too). Persuaded them to temporarily give access and the callout worked straight away.... hope this info is useful to others in the community!

 

This was selected as the best answer
dkadordkador

Cool, glad you got it worked out.