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
Steve MaxSteve Max 

Persisting HTTP Cookies in Web Service call out version 2

I am trying to call a third party Web Service.  I have generated Apex classes from a WSDL file.  I am getting the following error message:

External Account Number: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html'

I think it's because I am not persisting a cookie.  I got it working in VB.

The following VB code works

Sub Main()

Dim service As New Service

service.CookieContainer = New System.Net.CookieContainer

service.Login()

...

service.Logout()

End Sub

 

Here is the corresponding code in Java (using Apache Axis)

public static void main(String[] args)

{

UseSessionsServiceLocator locator = new UseSessionsServiceLocator();

locator.setMaintainSession(true);

ServiceSoap service = locator.getServiceSoap();

service.login();

...

service.logout();

}

 

How do I achieve this in Apex?  Below is what I have so far:

global class getAccountCyber {

     webservice static String getCyberAccount() {

          String exAccNo='Acme Hotel';

          try {

               AtexEnterpriseWeb.ServiceSoap ss = new AtexEnterpriseWeb.ServiceSoap();

               // I THINK I NEED A COOKIE OBJECT IN HERE! BUT WHICH ONE?

               ss.Login();

               // ...

               ss.Logout();

          } catch (exception e) {

               exAccNo = e.getMessage();

               System.debug(e.getMessage());

          }

     return exAccNo;

     }

}

 

Kind regards (and thanks in advance),

Max

 



Message Edited by Steve Max on 11-05-2008 09:12 PM

Message Edited by Steve Max on 11-05-2008 09:14 PM