标签: apex-code

Salesforce 中的 SOAP 安全性

我正在尝试更改当前如下所示的 Web 服务调用标头的 wsdl2apex 代码:
<env:Header>
<Security xmlns="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd">
<UsernameToken Id="UsernameToken-4">
<Username>test</Username>
<Password>test</Password>
</UsernameToken>
</Security>
</env:Header>

看起来像这样:
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-4" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>Test</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Test</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>

一个问题是我无法弄清楚如何更改元素的命名空间(或者即使它们的名称很重要)。第二个问题是将 Type 属性放在 Password 元素上。

任何人都可以提供任何可能有帮助的信息吗?

谢谢

ws-security soap header salesforce apex-code

2
推荐指数
1
解决办法
5452
查看次数

Salesforce - 无效的构造函数名称错误

我正在构建一个控制器来显示Visualforce页面上自定义对象的数据.这是我的班级:

public class myController {

    Opportunity opp;
    list<Leg__c> legs;

    public Opportunity getOpp() {
        if(opp == null)
            opp = [select name, Primary_Contact__r.name, Primary_Contact__r.email, Primary_Contact__r.phone from Opportunity
                where id = :ApexPages.currentPage().getParameters().get('id')];
        return opp;
    }
    public getLegs() {
        legs = [select Departure__c, Arrival__c from Leg__c
                where Opportunity__c = :ApexPages.currentPage().getParameters().get('id')];
    }

}
Run Code Online (Sandbox Code Playgroud)

我无法编译!我一直在

错误:myController编译错误:无效的构造函数名称:第12行第12行的getLegs

我做错了什么,怎么能解决这个问题?

constructor controller class salesforce apex-code

2
推荐指数
1
解决办法
5049
查看次数

使用“|”分割字符串

我有一个字符串

&#124;      859706 &#124; Conficker infected host at 192.168.155.60    &#124;        5744 &#124;       7089 &#124;        5 &#124;                 4 &#124; 1309714576 &#124;
                1 &#124; completed           &#124; 
Run Code Online (Sandbox Code Playgroud)

我需要拆分 using | 当我给出以下拆分时,它只是管道( | )符号,我将数组的大小设为 0

columns=parts[i].split('&#124;');
Run Code Online (Sandbox Code Playgroud)

其中部分和列是字符串数组

java regex salesforce apex-code

2
推荐指数
1
解决办法
1869
查看次数

Apex 测试类 - System.NullPointerException:尝试取消引用空对象

测试类如下:我试图在测试类中设置 RecordType.Name,但它给了我消息“System.NullPointerException: Attempt to de-reference a null object class.TestAcctHierWarnDisplay.tstWarningDisplay1: line 45, column 3外部入口点”。记录类型存在。我不确定我错过了什么。在myacct.RecordType.Name = 'Master Account'处获取异常

salesforce apex-code

2
推荐指数
1
解决办法
7690
查看次数

测试在Salesforce中返回PageReference的方法

我在控制器中有一个方法

    public PageReference add() {
              insert technology;
              return null;
            }
Run Code Online (Sandbox Code Playgroud)

technology 是一个自定义对象.它有自己的getter和setter.如何测试这个方法

testing salesforce force.com visualforce apex-code

2
推荐指数
1
解决办法
8722
查看次数

如何使用force.com为Amazon Simple Email Service创建带附件(MIME)的电子邮件?

我想通过force.com通过Amazon Web Services的简单电子邮件服务服务创建带附件的电子邮件,因为force.com组织范围内每天限制1,000封单个出站电子邮件.

SendEmailAWS'SES中的方法不支持附件,但它们通过SendRawEmail(至少对您有兴趣发送的大多数文件类型)提供对原始电子邮件的支持.

据我所知,你无法获得SingleEmailMessage的原始版本,需要自己构建它.

如何在APEX中创建多部分MIME电子邮件?

salesforce amazon-web-services apex-code amazon-ses

2
推荐指数
1
解决办法
1653
查看次数

未来方法销售人员的测试覆盖率

您好,我试图覆盖一个几乎没有未来方法(用于 Web 服务调用)和具体静态方法的类。但是在调用 future 方法后,我无法调用其他方法...您能告诉我如何覆盖 future 方法和 Web 服务调用吗?

我的班级结构:

public with sharing class AccountSynchController { 
 @future (callout=true)
    public static void importAccount(Set<Id> ids) {

    }
 @future (callout=true)
    public static void importContact(Set<Id> ids) {

    }
}

[future methods are called from trigger]

Test Class Code : 


        VAT__c testVat = new VAT__c();
    testVat.Code__c = '3';
    insert testVat;        

        Account testAccount = new Account();
        testAccount.Name = 'Test Account';
        testAccount.VATSales__c = testVat.Id;
        testAccount.VATPurchase__c = testVat.Id;
        testAccount.KvK_Nummer__c = '12312312';
        testAccount.PhoneExt__c = '12312312';
        testAccount.Website = '12312312';
        testAccount.BillingPostalCode …
Run Code Online (Sandbox Code Playgroud)

web-services salesforce apex-code

2
推荐指数
1
解决办法
6942
查看次数

为什么Salesforce阻止我使用包含关系的查询创建推送主题?

当我在开发者控制台中执行此代码时

PushTopic pushTopic = new PushTopic();
pushTopic.ApiVersion = 23.0;
pushTopic.Name = 'Test';
pushTopic.Description = 'test';
pushtopic.Query = 'SELECT Id, Account.Name FROM Case';
insert pushTopic;
System.debug('Created new PushTopic: '+ pushTopic.Id);
Run Code Online (Sandbox Code Playgroud)

我收到此消息:

致命错误System.DmlException:插入失败.第0行的第一个例外; 第一个错误:INVALID_FIELD,不支持关系:[QUERY]

相同的查询在查询编辑器上运行正常,但是当我将其分配给推送主题时,我得到了INVALID_FIELD异常.

如果底线是异常消息所说的内容,Push Topic对象不支持这种关系,那么如何创建一个Push Topic对象来返回我正在寻找的数据?

exception salesforce soql apex-code sql-insert

2
推荐指数
1
解决办法
1659
查看次数

Apex/Salesforce:从月份的字符串表示形式获取数字月份值

我希望用更好的不太详细的过程替换以下函数,用于从字符串确定数字月份值。有谁知道是否有可用于此目的的日期/日期时间函数?我没有注意到哪一个可以满足我的需要。

代码中的文本字符串正是我接收它们的方式。

预先感谢您的任何帮助。

private static Integer convertMonthTextToNumber(String matrixMonth){
    if(matrixMonth == 'January'){
        return 1;   
    }else if(matrixMonth == 'February'){
        return 2;   
    }else if(matrixMonth == 'March'){
        return 3;   
    }else if(matrixMonth == 'April'){
        return 4;   
    }else if(matrixMonth == 'May'){
        return 5;       
    }else if(matrixMonth == 'June'){            
        return 6;   
    }else if(matrixMonth == 'July'){
        return 7;   
    }else if(matrixMonth == 'August'){
        return 8;   
    }else if(matrixMonth == 'September'){
        return 9;   
    }else if(matrixMonth == 'October'){
        return 10;  
    }else if(matrixMonth == 'November'){
        return 11;  
    }else{
        return 12;
    }
}
Run Code Online (Sandbox Code Playgroud)

datetime date salesforce apex-code

2
推荐指数
1
解决办法
5784
查看次数

SFDC Apex 代码:从“Future”方法访问类级静态变量

我需要从我的 ApexController 类中调用 Web 服务。为此,我有一个带有属性 @future (callout=true) 的 asycn 方法。Web 服务调用需要引用在 VF 页面的保存调用中填充的对象。

由于静态(未来)调用并不会将所有对象作为方法参数传入,因此我计划将数据添加到静态 Map 中,并在静态方法中访问该数据以执行 Web 服务调用。但是,静态 Map 对象正在重新初始化,并且在静态方法中为 null。

如果有人能给我一些关于如何解决这个问题的指示,我将非常感激。谢谢!

这是代码片段:

      private static Map<String, WidgetModels.LeadInformation> leadsMap;

       ....
       ......
        public PageReference save() {

       if(leadsMap == null){
           leadsMap = new Map<String, WidgetModels.LeadInformation>();
        }
        leadsMap.put(guid,widgetLead);

       }
        //make async call to Widegt Webservice
        saveWidgetCallInformation(guid)

       //async call to widge webserivce  
      @future (callout=true)
      public static void saveWidgetCallInformation(String guid) {
        WidgetModels.LeadInformation cachedLeadInfo =   
        (WidgetModels.LeadInformation)leadsMap.get(guid);
      .....
      //call websevice

      }
Run Code Online (Sandbox Code Playgroud)

asynchronous web-services salesforce apex-code apex

2
推荐指数
1
解决办法
4282
查看次数