Salesforce WebServiceCallout.invoke 方法的参数是什么? [英] What are the parameters for the Salesforce WebServiceCallout.invoke method?

查看:24
本文介绍了Salesforce WebServiceCallout.invoke 方法的参数是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 Salesforce 用于调用远程 Web 服务的 invoke 方法的参数.我有一个可以调用的服务,但是服务 WSDL 没有定义安全要求,所以我希望我可以手动添加该信息(这些服务使用通过 Soap 标头传递的 WS-Security).

I would like to know the parameters for the invoke method used by Salesforce to invoke remote web services. I have a service that I'm suposed to be able to invoke, but the service WSDL does not define the security requirements, so I'm hoping I can add that information manually (The services uses WS-Security passed through Soap headers).

这是我(认为我)到目前为止所知道的:

Here is what I (think I) know so far:

WebServiceCallout.invoke(
  Class servicePort, //Usually set to "this", contains httpheader info as well as ? 
  request_x, //Request object, defining schema, properties, and field order
  response_map_x, //Response object, defining schema, properties, and field order
  new String[]{
  String endpoint, //Endpoint of the service
  String ?, //what is this?
  String methodSchema, //Schema for the request object?
  String method, //Name of the request method?
  String responseSchema, //Schema for the response object?
  String response, //Name of the response object?
  String responseClass} //Name of the Apex class the response will be converted to
);

有人可以帮忙填补空白吗?

Can anyone help fill in the gaps?

推荐答案

以下是我目前对 WebServiceCallout.invoke 的发现:

Here's what I have discovered so far for WebServiceCallout.invoke:

Object servicePort - A class with the following variables:
  String enpoint_x: containing the service endpoint (not sure if necessary)
  Map<String,String> inputHttpHeaders_x: custom httpHeaders
  Map<String,String> outputHttpHeaders_x: I think this is the httpHeaders that were returned
  String clientCertName_x: Used in configuring an SSL cert?
  String clientCert_x: Used in configuring an SSL cert?
  String clientCertPassword: Used in configuring an SSL cert?
  Integer timeout_x: How long (in milliseconds?) to wait for the response
  String[] ns_map_type_info: The first String is the namespace of the service schema, the second is the name of the object that contains the Apex classes defining the schema objects
Object request_x - The Apex object that will form the XML schema object
Map<String, Object> response_map_x - Object is the object that the result is to be unserialized into. String is the name of Object variable.
String[] {
  endpoint - The service endpoint
  soapAction - If the service call requires a soapAction, put it here. Otherwise leave blank.
  methodSchema - Schema for the request object
  method - Name of the request method
  responseSchema Schema for the response
  responseClass The Apex class that the response will be unserialized into
}

此外,可以通过在 servicePort 类中创建对象以及具有相同变量名称的字符串+_hns",用于指定该对象的命名空间:

In addition, Soap headers can be inserted by creating an object in the servicePort class as well as a String with the same variable name+"_hns" that specifies the namespace for that object:

public SoapSecurity Security;
private String Security_hns = "Security=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";

顶点 XML 架构对象应包含每个子元素(或属性)的变量.变量名称与特定模式匹配的数组定义了对象变量在 xml 中的使用方式.

The apex XML Schema objects should contain variables for each child element (or attribute). Arrays whose variable names match certain patterns define how the object variables are used in the xml.

给定以下示例 XML:

Given the following example XML:

<foo a="b"><bar>baz</bar></foo>

Apex 类将是这样的:

The Apex classes would be something like this:

public class MyService {
   public class bar {
      public String bar;
      private String[] bar_type_info = new String[] {'bar','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
      private String[] apex_schema_type_info = new String[] {'http://schema.myservice.com', 'false', 'false'};
      private String[] field_order_type_info = new String[] {'bar'};
   }

   public class foo {
      public MyService.bar bar;
      public String a;
      private String[] bar_type_info = new String[] {'bar','http://schema.myservice.com','bar','0','1','true'};
      private String[] a_att_info = new String[] {'a'};
      private String apex_schema_type_info = new String[] {'http://schema.myservice.com','false','false'};
      private String[] field_order_type_info = new String[] {'bar'};
   }
}

以下是这些对象的(简要)分类:

Here's a (brief) breakdown of these objects:

如果变量代表另一个 XML 元素或文本节点,则需要有一个匹配的 _type_info String[] 例如bar_type_info.这个数组的元素是:1. XML 元素名称2. 架构3. XML 类型4. 最小发生5. maxOccurs(无界设置为'-1')6. isNillable

If the variable represents another XML element or a text node, then there needs to be a matching _type_info String[] e.g. bar_type_info. The elements of this array are: 1. XML element name 2. Schema 3. XML type 4. minOccurs 5. maxOccurs (set to '-1' for unbounded) 6. isNillable

如果变量代表一个属性,那么必须有一个匹配的 _att_info String[] 例如a_type_info.Thise 只包含属性的 XML 名称.

If the variable represents an attribute, then there must be a matching _att_info String[] e.g. a_type_info. Thise simply contains the XML name of the attribute.

请注意,如果类变量名称是保留字,则将 _x 附加到它,例如酒吧_x.这会影响其他变量名称:bar_x_type_info.Apex 开发人员指南解释了他们的名称规则,但是如果您手动创建它,我认为您可以给它任何您想要的名称——数组决定了 XML 元素名称...

Note that if an class variable name is a reserved word, then _x is appended to it e.g. bar_x. This would affect the other variables names: bar_x_type_info. The Apex Developer's Guide explains their rules for names, but if you are manually creating it, I think you can give it whatever name you want--the arrays determine the XML element name...

我还没有找到一种方法来表示也包含属性的简单 XML 类型:例如

I have not found a way to represent a simple XML type that also contains an attribute: e.g.

<foo bar="baz">bar</foo>

apex_schema_type_info 数组指定有关由类表示的 XML 元素的信息:1. 架构2. 'true' 如果 elementFormDefault="qualified"3. 'true' 如果 attributeFormDefault="qualified"

The apex_schema_type_info array specifies information about the XML element represented by the class: 1. Schema 2. 'true' if elementFormDefault="qualified" 3. 'true' if attributeFormDefault="qualified"

我对 2 和 3 的实际作用仍然相当模糊,但它似乎影响子元素(和属性)继承父命名空间的方式(无论是隐含的还是必须在生成的 XML 中指定).

I'm still rather fuzzy on what 2 and 3 actually do, but it seems to affect how child elements (and attributes) inherit the parent namespace (whether it's implied or must be specified in the resulting XML).

field_order_type_info 只是指定子元素的顺序.

field_order_type_info simply specifies the order of the child elements.

请随时纠正或澄清...

Please feel free to correct or clarify...

这篇关于Salesforce WebServiceCallout.invoke 方法的参数是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆