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

问题描述

我想知道使用Salesforce来调用远程Web服务的invoke方法的参数。我有我suposed才能够调用服务,但该服务的WSDL没有定义的安全要求,所以我希望我可以手动添加信息(该服务使用的WS-Security通过SOAP头传递)。

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
}

此外,SOAP头可以通过创建SERVICEPORT类的物体插入以及
用相同的变量名+_ HNS一个字符串,指定该对象的命名空间:

In addition, Soap headers can be inserted by creating an object in the servicePort class as well asa 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 Schema对象应包含每个子元素(或属性)的变量。其数组变量名称与特定模式匹配定义对象变量是如何在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:

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

尖顶类将是这样的:

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:

如果变量重presents另一个XML元素或文本节点,则需要有_type_info的String []例如匹配bar_type_info。这个数组的元素是:
1,XML元素名称
2.架构
3. XML类型
4.的minOccurs
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 name2. Schema3. XML type4. minOccurs5. maxOccurs (set to '-1' for unbounded)6. isNillable

如果变量重presents属性,那么就必须_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例如追加到它bar_x。这会影响到其他变量名:bar_x_type_info。尖顶开发人员指南解释了他们的名字的规则,但如果你是手动创建它,我想你可以给它任何你想要的名称 - 阵列确定的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...

我还没有找到一种方法来重新present还包含一个属性一个简单的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阵列指定有关再由类psented $ P $的XML元素信息:
1.模式
2.真,如果将elementFormDefault =合格
3.真,如果attributeFormDefault =合格

The apex_schema_type_info array specifies information about the XML element represented by the class:1. Schema2. '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方法的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 06:54