• AbhiSFDC
  • NEWBIE
  • 0 Points
  • Member since 2011

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

Hi, 

 

I am trying to use webservice callout, but i am getting following error ..

 

System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'

 

Step 1: I got the WSDL and generated apex class from it, following method i am calling from VF page

 

public schemasDatacontractOrg200407CebCws.EmailTemplate GetEmailTemplate(String systemName) {
    tempuriOrg.GetEmailTemplate_element request_x = new tempuriOrg.GetEmailTemplate_element();
    tempuriOrg.GetEmailTemplateResponse_element response_x;
    request_x.systemName = systemName;
    Map<String, tempuriOrg.GetEmailTemplateResponse_element> response_map_x = new Map<String,           tempuriOrg.GetEmailTemplateResponse_element>();
    response_map_x.put('response_x', response_x);
    WebServiceCallout.invoke(
      this,
      request_x,
      response_map_x,
      new String[]{endpoint_x,
      'http://tempuri.org/IEmailWebService/GetEmailTemplate',
       'http://tempuri.org/',
       'GetEmailTemplate',
       'http://tempuri.org/',
       'GetEmailTemplateResponse',
       'tempuriOrg.GetEmailTemplateResponse_element'}
      );
response_x = response_map_x.get('response_x');
return response_x.GetEmailTemplateResult;
}

 

Step 2 : I executed anonymously i ecllipse 

 

    tempuriOrg.Cws_Poc_EmailWebService emailServices = 

    new tempuriOrg.Cws_Poc_EmailWebService ();
    emailServices.timeout_x = 90000 ;
    emailServices.endpoint_x = 'http://sbws-bat.ceb.com/EmailWebService.svcl';
    schemasDatacontractOrg200407CebCws.EmailTemplate emailTemplate =
    new schemasDatacontractOrg200407CebCws.EmailTemplate ();
    System.Debug ('Email template : ' + emailServices.GetEmailTemplate('ResetPassword'));

 

Step 3 : I got error

  

   

DEBUG LOG
23.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;VALIDATION,INFO;WORKFLOW,INFO
Execute Anonymous: tempuriOrg.Cws_Poc_EmailWebService emailServices =
Execute Anonymous: new tempuriOrg.Cws_Poc_EmailWebService ();
Execute Anonymous: emailServices.timeout_x = 90000 ;
Execute Anonymous: emailServices.endpoint_x = 'http://sbws-bat.ceb.com/EmailWebService.svcl';
Execute Anonymous: schemasDatacontractOrg200407CebCws.EmailTemplate emailTemplate =
Execute Anonymous: new schemasDatacontractOrg200407CebCws.EmailTemplate ();
Execute Anonymous: System.Debug ('Email template : ' + emailServices.GetEmailTemplate('ResetPassword'));
23:57:07.037 (37358000)|EXECUTION_STARTED
23:57:07.037 (37369000)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
23:57:07.038 (38004000)|METHOD_ENTRY|[3]|01pV00000004Xnr|tempuriOrg.tempuriOrg()
23:57:07.038 (38033000)|METHOD_EXIT|[3]|tempuriOrg
23:57:07.038 (38046000)|CONSTRUCTOR_ENTRY|[2]|01pV00000004Xnr|<init>()
23:57:07.038 (38098000)|CONSTRUCTOR_EXIT|[2]|01pV00000004Xnr|<init>()
23:57:07.038 (38126000)|METHOD_ENTRY|[3]|01pV00000004Xnt|schemasDatacontractOrg200407CebCws.schemasDatacontractOrg200407CebCws()
23:57:07.038 (38144000)|METHOD_EXIT|[3]|schemasDatacontractOrg200407CebCws
23:57:07.038 (38152000)|CONSTRUCTOR_ENTRY|[6]|01pV00000004Xnt|<init>()
23:57:07.038 (38238000)|CONSTRUCTOR_EXIT|[6]|01pV00000004Xnt|<init>()
23:57:07.038 (38275000)|METHOD_ENTRY|[7]|01pV00000004Xnr|tempuriOrg.Cws_Poc_EmailWebService.GetEmailTemplate(String)
23:57:07.039 (39021000)|CONSTRUCTOR_ENTRY|[126]|01pV00000004Xnr|<init>()
23:57:07.039 (39067000)|CONSTRUCTOR_EXIT|[126]|01pV00000004Xnr|<init>()
23:57:07.044 (44441000)|CALLOUT_REQUEST|[131]|tempuriOrg.GetEmailTemplate_element request_x::SFDC_STACK_DEPTH=1 SOAPAction="http://tempuri.org/IEmailWebService/GetEmailTemplate" User-Agent=SFDC-Callout/23.0 Accept=text/xml Content-Type=text/xml; charset=UTF-8
23:57:07.046 (46073000)|EXCEPTION_THROWN|[131]|System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'

 

Please let me know how to fix this issue.

We are integrating different systems with Salesforce where we will be consuming multiple web services. Due to security reasons we decided following approach.

 

  1. Create  Self-Signed Certificate in Salesforce.
  2. Create Signature using this certificate Signature = “Certificate Unique Name + Today DateTime “.
  3. We will be using UserName , Password and above Signature to login to Authentication system which will return Security Token

 

So here are my questions

  1. How I can create Signature using certificate not its unique label like below example. How I can get certificate value.
  2. Is their sample code you can mail me.

 

Any sort of help is appreciated. This is the 1st time we will be using certificates in code.

 

Hi Everyone,

 

I'm signing a token using the APEX Crypto.sign() method.

I'm then trying to verify/decrypt the signature in C# .NET but I'm not having much luck.

 

Has anyone had any experience with this? What's the correct approach methodology? (Even if not in .NET but in something else?)

 

I've generated the PKCS8 private key using openssl.exe, and salesforce seems to sign it without error.

I've then tried to use the public key in C# .NET but I'm not seeing the right result.

 

Any thoughts/tips would be appreciated.

 

Thanks,

-lucena