• Manoj_
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 6
    Replies

I have an issue reading the headers from the soap response and here are the steps I did

1. Create the class using wsdl2apex

2. Made a webservice callout to the logon method and the method was successful and it returned a logon success message

3. The webservice callout also returns the sessionid in the response headers. I am not able to read the response headers from the callout.

4. Salesforce debug log shows the webservice callout profiling information. I can see the following line that contains the headers

9:53:31.492|CALLOUT_RESPONSE|[66,13]|<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header><Header xmlns="http://www.twinfield.com/"><SessionID>6ad74r65-2333c-43tf1-9501-adf31d5r4da2</SessionID></Header></soap:Header><soap:Body><LogonResponse xmlns="http://www.twinfield.com/"><LogonResult>Ok</LogonResult><nextAction>None</nextAction><cluster>https://c1.twinfield.com</cluster></LogonResponse></soap:Body></soap:Envelope>
5. Can you please help me on how to read the response headers in this case? I tried every possibility in vain.

================================================================================================

//Generated by wsdl2apex

public class WSDLClassTwinfieldSession {
    public static WSDLClassTwinfieldSession.LogonResponse_element login(String user_x,String password,String organisation){
        WSDLClassTwinfieldSession.LogonResponse_element logonResponse = null;
        WSDLClassTwinfieldSession.SessionSoap soap = new WSDLClassTwinfieldSession.SessionSoap();
        soap.outputHttpHeaders_x = new Map<string, string>();
        logonResponse = soap.Logon(user_x, password, organisation);
        System.debug('Logon Response ='+logonResponse);
        System.debug('headers: ' + soap.outputHttpHeaders_x);
        return logonResponse;
    }
    public class SessionSoap {
        public String endpoint_x = 'https://login.twinfield.com/webservices/session.asmx';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        public WSDLClassTwinfieldSession.Header Header;
        private String Header_hns = 'Header=http://www.twinfield.com/';
        private String[] ns_map_type_info = new String[]{'http://www.twinfield.com/', 'WSDLClassTwinfieldSession'};
        public void Abandon() {
            WSDLClassTwinfieldSession.Abandon_element request_x = new WSDLClassTwinfieldSession.Abandon_element();
            WSDLClassTwinfieldSession.AbandonResponse_element response_x;
            Map<String, WSDLClassTwinfieldSession.AbandonResponse_element> response_map_x = new Map<String, WSDLClassTwinfieldSession.AbandonResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://www.twinfield.com/Abandon',
              'http://www.twinfield.com/',
              'Abandon',
              'http://www.twinfield.com/',
              'AbandonResponse',
              'WSDLClassTwinfieldSession.AbandonResponse_element'}
            );
            response_x = response_map_x.get('response_x');
        }
        public WSDLClassTwinfieldSession.LogonResponse_element Logon(String user_x,String password,String organisation) {
            WSDLClassTwinfieldSession.Logon_element request_x = new WSDLClassTwinfieldSession.Logon_element();
            WSDLClassTwinfieldSession.LogonResponse_element response_x;
            request_x.user_x = user_x;
            request_x.password = password;
            request_x.organisation = organisation;
            Map<String, WSDLClassTwinfieldSession.LogonResponse_element> response_map_x = new Map<String, WSDLClassTwinfieldSession.LogonResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://www.twinfield.com/Logon',
              'http://www.twinfield.com/',
              'Logon',
              'http://www.twinfield.com/',
              'LogonResponse',
              'WSDLClassTwinfieldSession.LogonResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x;
        }
    }
    public class LogonResponse_element {
        public String LogonResult;
        public String nextAction;
        public String cluster;
        private String[] LogonResult_type_info = new String[]{'LogonResult','http://www.twinfield.com/','LogonResult','1','1','false'};
        private String[] nextAction_type_info = new String[]{'nextAction','http://www.twinfield.com/','LogonAction','1','1','false'};
        private String[] cluster_type_info = new String[]{'cluster','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.twinfield.com/','true','false'};
        private String[] field_order_type_info = new String[]{'LogonResult','nextAction','cluster'};
    }
    public class Header {
        public String SessionID;
        private String[] SessionID_type_info = new String[]{'SessionID','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.twinfield.com/','true','false'};
        private String[] field_order_type_info = new String[]{'SessionID'};
    }
    public class Logon_element {
        public String user_x;
        public String password;
        public String organisation;
        private String[] user_x_type_info = new String[]{'user','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] password_type_info = new String[]{'password','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] organisation_type_info = new String[]{'organisation','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.twinfield.com/','true','false'};
        private String[] field_order_type_info = new String[]{'user_x','password','organisation'};
    }
}

==========================================================================================

I am calling the above class in the following way

WSDLClassTwinfieldSession.login('username','password','org');

I am getting when trying to generate apex classes from a WSDL generated by Inforamtica Web Service.
 
Error: Unable to find element for {http://www.informatica.com/wsdl/}t_targetResponse
 
I don't know what can be done with this element. Has anybody faced this kind of issue ?
 
Here is my WSDL file.

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:n="http://www.informatica.com/wsdl/" xmlns:infa="http://www.informatica.com/" targetNamespace="http://www.informatica.com/" xmlns="http://schemas.xmlsoap.org/wsdl/">
 <wsdl:types>
 <xsd:schema targetNamespace="http://www.informatica.com/wsdl/" xmlns="http://www.informatica.com/wsdl/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:infatype="http://www.informatica.com/types/" elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/http/" />
  <xsd:element name="ws_ip_op_resp_2Response" type="ws_ip_op_resp_2ResponseType" />
 <xsd:complexType name="ws_ip_op_resp_2RequestType">
 <xsd:sequence>
 <xsd:element name="ws_ip_op_resp_2RequestElement">
 <xsd:complexType>
 <xsd:sequence>
 <xsd:element name="Address_ID" minOccurs="0" maxOccurs="1">
 <xsd:simpleType>
  <xsd:restriction base="xsd:decimal" />
  </xsd:simpleType>
  </xsd:element>
  </xsd:sequence>
  </xsd:complexType>
  </xsd:element>
  </xsd:sequence>
  </xsd:complexType>
 <xsd:complexType name="ws_ip_op_resp_2ResponseType">
 <xsd:sequence>
 <xsd:element name="ws_ip_op_resp_2ResponseElement">
 <xsd:complexType>
 <xsd:sequence>
 <xsd:element name="Address_ID" minOccurs="0" maxOccurs="1">
 <xsd:simpleType>
  <xsd:restriction base="xsd:decimal" />
  </xsd:simpleType>
  </xsd:element>
  </xsd:sequence>
  </xsd:complexType>
  </xsd:element>
  </xsd:sequence>
  </xsd:complexType>
  <xsd:element name="ws_ip_op_resp_2Request" type="ws_ip_op_resp_2RequestType" />
  </xsd:schema>
  </wsdl:types>
 <wsdl:message name="t_targetOut">
  <wsdl:part name="parameters" element="n:t_targetResponse" />
  </wsdl:message>
 <wsdl:message name="ws_ip_op_resp_2In">
  <wsdl:part name="parameters" element="n:ws_ip_op_resp_2Request" />
  </wsdl:message>
 <wsdl:portType name="Salesforce_ip_op_resp2Port">
 <wsdl:operation name="Salesforce_ip_op_resp2Operation">
  <wsdl:input message="infa:ws_ip_op_resp_2In" />
  <wsdl:output message="infa:t_targetOut" />
  </wsdl:operation>
  </wsdl:portType>
 <wsdl:binding name="Salesforce_ip_op_resp2Binding" type="infa:Salesforce_ip_op_resp2Port">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
 <wsdl:operation name="Salesforce_ip_op_resp2Operation">
  <soap:operation soapAction="" style="document" />
 <wsdl:input>
  <soap:body use="literal" />
  </wsdl:input>
 <wsdl:output>
  <soap:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
 <wsdl:service name="Salesforce_ip_op_resp2">
 <wsdl:port name="Salesforce_ip_op_resp2Port" binding="infa:Salesforce_ip_op_resp2Binding">
  <soap:address location="https://gnwlonsdapomna:7343/wsh/services/RealTime/Salesforce_ip_op_resp2" />
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>
Thanks,
Deepak

I have a situation where my client needs to change the "Master" record in a master-detail relationship. The only way to do this, of course, is to clone the old record to a new record while you change the master record. Then you delete the old record. This I can do.

 

The problem is that the old records are auto-numbered, and we want to preserve the numbers. I can do this by MANUALLY going in and turning off auto-numbering, setting the new record to have the same name as the old record, and then turning auto-numbering back on, being very careful to RESET the next number correctly.

 

As an aside, it would be really nice to expose the LAST NUMBER or NEXT NUMBER for an auto-numbered field to the api. As a work-around, I do a query sorted by Name DESC with Limit 1 to return the record with the highest number.

 

I would love to do all this in a single apex process, but the controls for auto-numbering are not exposed. So I have resigned myself turning it off and on manually, outside of the automated process.

 

But my automated process has code that wants to reset the "Name" of the record. I have tests in the code to prevent the code from executing if auto-numbering is on - you can query to see if a field is auto-numbered. But, when developing the code, you have to turn auto-numbering off because the code that contains a Save to an auto-numbered field, even if not executing, will not save.

 

The problem becomes compounded when you create test routines. If auto-numbering is off, the test routines work fine. But when you turn it back on, the test fails.

 

This means you cannot deploy to production unless you turn auto-numbering off in production during the installation. This is not too bad.

 

But the next time you want to install new code, you have to remember to turn off auto-numbering again, and then back on. If you don't, all Apex testing fails because the code that writes to the auto-number field will not even start to execute in the testing process. The code, by the way, works fine with auto-numbering on because it does not process data unless auto-numbering is off.

 

I would appreciate any suggestions from the peanut gallery.

I'm a self-proclaimed novice programmer, especially with Apex.  I'm working with a WSDL based webservice callout and not seeing what I would expect.  Any perspective would be appreciated.  The following sample is broken into three portions(urls, authentication redacted).  ...1.Asynchronous Callout 2.WSDL2APEX Class 3.Debug log of @future callout. 

 

 

/////////////////////////////////////////////////////Callout///////////////////////////////////////////////////// public class LeadIVAULTCallout { @future (callout=true) public static void LeadIVAULTCalloutPOST(Set <Id> leadPDFIDs) { Map<ID,Attachment> leadPDFMap = new Map<ID,Attachment>( [select attachment.ID from Attachment where id IN :leadPDFIDs] ) ; for( ID i : leadPDFIDs ){ Attachment STLeadPDF = leadPDFMap.get(i); String DocumentID = STLeadPDF.ID; String applicationId = 'GFT-CUST-99YR'; //docSample.DocSamplePort stub = new docSample.DocSamplePort(); globalforexSpringthroughComServices.SFDocumentManagementSoap stub = new globalforexSpringthroughComServices.SFDocumentManagementSoap(); stub.inputHttpHeaders_x = new Map<String, String>(); //Setting a basic authentication header stub.inputHttpHeaders_x.put('Authorization', <VALUE>); globalforexSpringthroughComServices.SFResult Stub2 = Stub.QueueDocument(DocumentID,applicationId); stub.outputHttpHeaders_x = new Map<String, String>(); String myHeader = stub.outputHttpHeaders_x.get('My-Header'); system.debug('headers: ' + stub.outputHttpHeaders_x + myHeader); } } } /////////////////////////////////////////////////////wsdl2apex///////////////////////////////////////////////////// //Generated by wsdl2apex public class globalforexSpringthroughComServices { public class SFDocumentManagementSoap { public String endpoint_x = 'http://<URLHERE>'; public Map<String,String> inputHttpHeaders_x; public Map<String,String> outputHttpHeaders_x; public String clientCert_x; public String clientCertPasswd_x; public Integer timeout_x; public globalforexSpringthroughComServices.AuthSoapHeader AuthSoapHeader; private String AuthSoapHeader_hns = 'AuthSoapHeader=http://<URLHERE>'; private String[] ns_map_type_info = new String[]{'http://<URLHERE>', 'globalforexSpringthroughComServices'}; public globalforexSpringthroughComServices.SFResult QueueDocument(String documentId,String applicationId) { globalforexSpringthroughComServices.QueueDocument_element request_x = new globalforexSpringthroughComServices.QueueDocument_element(); globalforexSpringthroughComServices.QueueDocumentResponse_element response_x; request_x.documentId = documentId; request_x.applicationId = applicationId; Map<String, globalforexSpringthroughComServices.QueueDocumentResponse_element> response_map_x = new Map<String, globalforexSpringthroughComServices.QueueDocumentResponse_element>(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, 'http://<URLHERE>', 'http://<URLHERE>', 'QueueDocument', 'http://<URLHERE>', 'QueueDocumentResponse', 'globalforexSpringthroughComServices.QueueDocumentResponse_element'} ); response_x = response_map_x.get('response_x'); return response_x.QueueDocumentResult; } } public class AuthSoapHeader { public String UserName; public String Password; private String[] UserName_type_info = new String[]{'UserName','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] Password_type_info = new String[]{'Password','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://globalforex.springthrough.com/services/','true','false'}; private String[] field_order_type_info = new String[]{'UserName','Password'}; } public class QueueDocumentResponse_element { public globalforexSpringthroughComServices.SFResult QueueDocumentResult; private String[] QueueDocumentResult_type_info = new String[]{'QueueDocumentResult','http://globalforex.springthrough.com/services/','SFResult','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://<URLHERE>','true','false'}; private String[] field_order_type_info = new String[]{'QueueDocumentResult'}; } public class QueueDocument_element { public String documentId; public String applicationId; private String[] documentId_type_info = new String[]{'documentId','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] applicationId_type_info = new String[]{'applicationId','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://<URLHERE>','true','false'}; private String[] field_order_type_info = new String[]{'documentId','applicationId'}; } public class SFResult { public Boolean success; public String returnValue; private String[] success_type_info = new String[]{'success','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'}; private String[] returnValue_type_info = new String[]{'returnValue','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://<URLHERE>','true','false'}; private String[] field_order_type_info = new String[]{'success','returnValue'}; } } /////////////////////////////////////////////////////Debug Log///////////////////////////////////////////////////// User Tom Fox Date 2/24/2010 8:18:53 PM EST Status Success Application Browser Request Type Api Operation FutureHandler Duration (ms) 282 Log Length 20100225011853.316:Class.LeadIVAULTCallout.LeadIVAULTCalloutPOST: line 34, column 1: headers: {}null

 

 

 

 

Am I crazy to expect more from my Debug Log?  I'm fearful that I'm not properly requesting the response from the webservice.

I generated an Apex class via WSDL2Apex, and I'm trying to debug an issue with maintaining session headers.  Regarding the section that talks about outputting headers here http://wiki.developerforce.com/index.php/Apex_Web_Services_and_Callouts

 

the  outputHttpHeaders_x Map is null, and it doesn't appear to do anything beside being created in the class.  How can I tewak the callout to actually write the header information to this Map so I can access and reuse the session header?

 

Here's the generated code snippet I'm trying to debug:

 

//Generated by wsdl2apex public class InstranetSession { public class logout_element { private String[] apex_schema_type_info = new String[]{'http://services.instranet.com','true','true'}; private String[] field_order_type_info = new String[]{}; } public class loginResponse_element { private String[] apex_schema_type_info = new String[]{'http://services.instranet.com','true','true'}; private String[] field_order_type_info = new String[]{}; } public class SessionServiceHttpPort { public String endpoint_x = 'https://hidden/kblive/ccil/services/SessionService'; public Map<String,String> inputHttpHeaders_x; public Map<String,String> outputHttpHeaders_x; public String clientCert_x; public String clientCertPasswd_x; public Integer timeout_x; private String[] ns_map_type_info = new String[]{'http://services.instranet.com', 'InstranetSession'}; public void login(String userLogin,String password) { InstranetSession.login_element request_x = new InstranetSession.login_element(); InstranetSession.loginResponse_element response_x; request_x.userLogin = userLogin; request_x.password = password; Map<String, InstranetSession.loginResponse_element> response_map_x = new Map<String, InstranetSession.loginResponse_element>(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, '', 'http://services.instranet.com', 'login', 'http://services.instranet.com', 'loginResponse', 'InstranetSession.loginResponse_element'} ); response_x = response_map_x.get('response_x'); } public void acceptLanguage(String languages) { InstranetSession.acceptLanguage_element request_x = new InstranetSession.acceptLanguage_element(); InstranetSession.acceptLanguageResponse_element response_x; request_x.languages = languages; Map<String, InstranetSession.acceptLanguageResponse_element> response_map_x = new Map<String, InstranetSession.acceptLanguageResponse_element>(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, '', 'http://services.instranet.com', 'acceptLanguage', 'http://services.instranet.com', 'acceptLanguageResponse', 'InstranetSession.acceptLanguageResponse_element'} ); response_x = response_map_x.get('response_x'); } public void logout() { InstranetSession.logout_element request_x = new InstranetSession.logout_element(); InstranetSession.logoutResponse_element response_x; Map<String, InstranetSession.logoutResponse_element> response_map_x = new Map<String, InstranetSession.logoutResponse_element>(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, '', 'http://services.instranet.com', 'logout', 'http://services.instranet.com', 'logoutResponse', 'InstranetSession.logoutResponse_element'} ); response_x = response_map_x.get('response_x'); } } public class acceptLanguageResponse_element { private String[] apex_schema_type_info = new String[]{'http://services.instranet.com','true','true'}; private String[] field_order_type_info = new String[]{}; } public class ServiceError { public String errorType; public String message; private String[] errorType_type_info = new String[]{'errorType','http://services.instranet.com','ServiceErrorType','0','1','true'}; private String[] message_type_info = new String[]{'message','http://www.w3.org/2001/XMLSchema','string','0','1','true'}; private String[] apex_schema_type_info = new String[]{'http://services.instranet.com','true','true'}; private String[] field_order_type_info = new String[]{'errorType','message'}; } public class login_element { public String userLogin; public String password; private String[] userLogin_type_info = new String[]{'userLogin','http://www.w3.org/2001/XMLSchema','string','1','1','true'}; private String[] password_type_info = new String[]{'password','http://www.w3.org/2001/XMLSchema','string','1','1','true'}; private String[] apex_schema_type_info = new String[]{'http://services.instranet.com','true','true'}; private String[] field_order_type_info = new String[]{'userLogin','password'}; } public class acceptLanguage_element { public String languages; private String[] languages_type_info = new String[]{'languages','http://www.w3.org/2001/XMLSchema','string','1','1','true'}; private String[] apex_schema_type_info = new String[]{'http://services.instranet.com','true','true'}; private String[] field_order_type_info = new String[]{'languages'}; } public class logoutResponse_element { private String[] apex_schema_type_info = new String[]{'http://services.instranet.com','true','true'}; private String[] field_order_type_info = new String[]{}; } }

 

 

 Can anyone tell me why the response headers aren't being written to the map and/or how to resolve this hole in teh WSDL2Apex generated code?  And, also, where oh where is the documentation on the WebServiceCallout Apex class?