您正在查看 Apigee Edge 文档。
转到
Apigee X 文档。 info
RequestVariableNotMessageType
错误代码
steps.servicecallout.RequestVariableNotMessageType
错误响应正文
{ "fault": { "faultstring": "ServiceCallout[policy_name]: request variable [variable_name] value is not of type Message", "detail": { "errorcode": "steps.servicecallout.RequestVariableNotMessageType" } } }
原因
如果服务调出政策的 <Request> 元素中指定的变量不是消息类型,则会出现此错误。如果变量是字符串或任何其他非消息类型,您将会看到此错误。
消息类型变量表示整个 HTTP 请求和响应。内置 Edge 流变量 request、response 和 message 都属于消息类型。如需详细了解消息变量,请参阅变量参考。
诊断
指出发生错误的服务调出政策以及类型错误的变量名称。您可以在错误响应的
faultstring元素中找到这两项。例如,在以下faultstring中,政策名称为ExecuteGeocodingRequest,变量为PostalCode:"faultstring": "ServiceCallout[ExecuteGeocodingRequest]: request variable PostalCode value is not of type Message"在失败的服务调出政策 XML 中,验证
<Request>元素中的变量名称是否与故障字符串中标识的变量名称(上方第 1 步中)一致。例如,以下政策指定了名为PostalCode的请求变量,该变量与faultstring中的相应内容一致:<?xml version="1.0" encoding="UTF-8&quo>t<; standalone="yes"? ServiceCallout >name=<"ExecuteGeocodingRequest&>quot;< Req>uest variable=&qu<ot;Postal>Code&<quot;/ ResponseG>eocodingR<esp>onse/Response HTTPTargetConnection U<RLht>tp://<maps.googleapis.com/m>a<ps/api/geocode/>json/URL /HTTPTargetConnection /ServiceCallout确定此变量是否为消息类型:
- 在首次定义变量的 API 代理软件包中找到代码。
- 在大多数情况下,您会在另一个先于服务调出政策执行的政策中发现问题变量已被创建并填充。例如,分配消息政策通常用于在 API 代理流程中创建和填充变量。
- 确定首次在其中定义并填充变量的政策后,您需要按以下方式确定该变量的类型:
- 检查
type属性的值(如果存在)。 - 如果
type属性不存在,则该变量将被视为字符串。
- 检查
- 如果变量的类型是非消息(例如字符串),则会导致错误。如需了解常见变量及其类型,请参阅变量参考文档。
例如,假设服务调出政策中引用的 PostalCode 变量创建于以下所示的分配消息政策中。请注意,系统为 PostalCode 分配的流变量值为 request.queryparam.postalcode。该值是一个字符串,因为变量赋值中没有 type 属性。
<?xml version="1.0" encoding="UTF-8&quo>t<; standalone="yes"?
AssignMessage n>ame="<;GenerateGeocodingRequest"
>AssignTo createN<ew=">true&<quo>t; type=&<quot;reques>t"Geocod<ingRequest/AssignTo
S>et
QueryParams
< QueryPa>ram name=&quo<t;address"{request.>queryparam.postalcode}/Query<Param
> QueryP<aram name="region&q>uot;{<request.que>ryparam.c<ountry}/Quer>yParam
< > < Qu>eryPa<ram >name=<"sensor&q>uot;false</Que>ryParam
< > /QueryPa<ram>s
VerbGET/Verb
/S<et
> As<signVariable
> < NamePostalCod>e/Name
< > Refre<quest>.querypar<am.>postalcode/Ref
/Assign<Vari>able
< AssignVaria>b<le
Nam>eCountry/Name
Refrequest.queryparam.country/Ref
/AssignVariable
/AssignMessage
现在,请回想服务调出政策的 <Request> 元素中使用的 PostalCode 变量:
<?xml version="1.0" encoding="UTF-8&quo>t<; standalone="yes"?
ServiceCallout >name=<"ExecuteGeocodingRequest&>quot;<
Req>uest variable=&qu<ot;Postal>Code&<quot;/
ResponseG>eocodingR<esp>onse/Response
HTTPTargetConnection
U<RLht>tp://<maps.googleapis.com/m>a<ps/api/geocode/>json/URL
/HTTPTargetConnection
/ServiceCallout
由于 PostalCode 不是消息类型(在此示例中为字符串),因此您会收到错误代码:steps.servicecallout.RequestVariableNotMessageType。
解决方法
确保在失败的服务调出政策的 <Request> 元素中设置的变量是存在的消息类型流变量,或者您也可以直接在服务调出政策中创建全新消息类型变量(如政策文档中所述)并加以使用。
要更正政策,您必须修改 <Request> 元素,指定类型为消息的现有变量或新变量。例如,在分配政策政策中设置的变量 GeocodingRequest 为消息类型,则该变量可以在服务调出政策中正常运行。例如:
<?xml version="1.0" encoding="UTF-8&quo>t<; standalone="yes"?
ServiceCallout >name=<"ExecuteGeocodingRequest"
> R<equest v>ariable="Geo<codingReq>uest&<quot;/
ResponseG>eocodingR<esp>onse/Response
HTTPTargetConnection
U<RLht>tp://<maps.googleapis.com/m>a<ps/api/geocode/>json/URL
/HTTPTargetConnection
/ServiceCallout
RequestVariableNotRequestMessageType
错误代码
steps.servicecallout.RequestVariableNotRequestMessageType
错误响应正文
{
"fault": {
"faultstring": "ServiceCallout[policy_name]: request variable [variable_name] value is not of type Request Message",
"detail": {
"errorcode": "steps.servicecallout.RequestVariableNotRequestMessageType"
}
}
}
原因
如果服务调出政策的 <Request> 元素中指定的变量不是请求消息类型,则会出现此错误。如果变量是响应消息类型、字符串或任何其他类型,您将会看到此错误。
消息类型变量表示整个 HTTP 请求和响应。内置 Edge 流变量 request、response 和 message 都属于消息类型。如需详细了解消息变量,请参阅变量参考。
诊断
指出发生错误的服务调出政策以及类型错误的变量名称。您可以在错误响应的
faultstring元素中找到这两项。例如,在以下faultstring中,政策名称为ExecuteGeocodingRequest,变量为var_response:"faultstring": "ServiceCallout[ExecuteGeocodingRequest]: request variable var_response value is not of type Message"在失败的服务调出政策 XML 中,验证
<Request>元素中的变量名称是否与故障字符串中标识的变量名称(上方第 1 步中)一致。例如,以下政策指定了名为var_response的请求变量,该变量与faultstring中的相应内容一致:<?xml version="1.0" encoding="UTF-8&quo>t<; standalone="yes"? ServiceCallout >name=<"ExecuteGeocodingRequest&qu>ot; < Reque>st variable="<;var_resp>onse&<quot;/ ResponseG>eocodingR<esp>onse/Response HTTPTargetConnection U<RLht>tp://<maps.googleapis.com/m>a<ps/api/geocode/>json/URL /HTTPTargetConnection /ServiceCallout确定变量是否为请求消息类型:
- 在首次定义变量的 API 代理软件包中找到代码。
- 在大多数情况下,您会在另一个先于服务调出政策执行的政策中发现问题变量已被创建并填充。例如,分配消息政策通常用于在 API 代理流程中创建和填充变量。
- 确定首次在其中定义并填充变量的政策后,您需要按以下方式确定该变量的类型:
- 检查
type属性的值(如果存在)。 - 如果
type属性不存在,则该变量将被视为字符串。
- 检查
- 如果变量的类型不是请求消息 类型,则会导致错误。如需了解常见变量及其类型,请参阅变量参考文档。
例如,假设服务调出政策中引用的 var_response 变量创建于以下所示的分配消息政策中。请注意,var_response 被授予的类型为 response。因此,var_response 变量的类型是响应消息。
<?xml version="1.0" encoding="UTF-8&quo>t<; standalone="yes"?
AssignMessage n>ame="<;GenerateGeocodingRequest"
>AssignTo createN<ew=">true&<quot; type="request"GeocodingRe>quest/Assign<To
As>signT<o c>reateNew=<"true&>quot; type=&q<uot;response"var_res>ponse/AssignTo
Set
<QueryParams>
<QueryParam name="ad>dress"{request.querypar<am.postalco>de}/QueryPara<m
QueryParam> name<="regi>on"{<request.quer>yparam.co<untr>y}/<Query>Param<
> < QueryParam> name=&qu<ot;s>ensor"<;fals>e/QueryPa<ram>
/QueryParams
< Ver>bGET/<Verb
/Set
> As<signVariable
> Na<mePo>stalCod<e/Nam>e
< Re>frequest.queryparam.postal<code>/Ref
< /AssignVari>a<ble
Assign>Variable
NameCountry/Name
Refrequest.queryparam.country/Ref
/AssignVariable
/AssignMessage
请回想服务调出政策的 <Request> 元素中使用的 var_response 变量。
<?xml version="1.0" encoding="UTF-8&quo>t<; standalone="yes"?
ServiceCallout >name=<"ExecuteGeocodingRequest&qu>ot;
< Reque>st variable="<;var_resp>onse&<quot;/
ResponseG>eocodingR<esp>onse/Response
HTTPTargetConnection
U<RLht>tp://<maps.googleapis.com/m>a<ps/api/geocode/>json/URL
/HTTPTargetConnection
/ServiceCallout
由于 var_response 不是请求消息类型(其类型为响应消息),因此您会收到错误代码:steps.servicecallout.RequestVariableNotRequestMessageType。
解决方法
确保在失败的服务调出政策的 <Request> 元素中设置的变量是存在的请求消息类型变量,或者您也可以直接在服务调出政策中创建全新的请求消息类型变量(如政策文档中所述)并加以使用。
要更正政策,您必须修改 <Request> 元素,以指定类型为请求消息的现有变量或新变量,那么该变量可以在服务调出政策中正常运行。例如:
<?xml version="1.0" encoding="UTF-8&quo>t<; standalone="yes"?
ServiceCallout >name=<"ExecuteGeocodingRequest"
> R<equest v>ariable="Geo<codingReq>uest&<quot;/
ResponseG>eocodingR<esp>onse/Response
HTTPTargetConnection
U<RLht>tp://<maps.googleapis.com/m>a<ps/api/geocode/>json/URL
/HTTPTargetConnection
/ServiceCallout
ExecutionFailed
错误代码
steps.servicecallout.ExecutionFailed
错误响应正文
{
"fault": {
"faultstring": "Execution of ServiceCallout [policy_name] failed. Reason: Host not reachable",
"detail": {
"errorcode": "steps.servicecallout.ExecutionFailed"
}
}
}
或
{
"fault": {
"faultstring": "Execution of ServiceCallout [policy_name] failed. Reason: ResponseCode [http_code] is treated as error",
"detail": {
"errorcode": "steps.servicecallout.ExecutionFailed"
}
}
}
可能的原因
造成此错误的可能原因包括:
| 原因 | 说明 |
| 网址无效或格式错误 | 服务调出政策中的目标网址格式错误,或者包含无效或无法访问的主机名。 |
| 后端服务器错误 | 后端服务器返回 4XX 或 5XX 错误响应。 |
原因:网址无效或格式错误
服务调出政策中的目标网址格式错误,或者包含无效或无法访问的主机名。
诊断
确定导致错误的服务调出政策。错误响应的
faultstring元素中会显示政策名称。例如,在以下faultstring中,失败的服务调出政策名称是ExecuteGeocodingRequest。"faultstring": "ServiceCallout[ExecuteGeocodingRequest]"在失败的服务调出政策中,检查
<URL>元素。如果该元素格式错误或包含无效或无法访问的主机名,则会导致此错误。例如,以下服务调出政策列明了无效的<URL>:<?xml version="1.0" encoding="UTF-8&quo>t<; standalone="yes"? ServiceCallout >name=<"ExecuteGeocodingRequest" > R<equest v>ariable="Geo<codingReq>uest&<quot;/ ResponseG>eocodingR<esp>onse/Re<spon>se < HTTPTargetConnectio>n< URLhtt>p:///URL /HTTPTargetConnection /ServiceCallout<URL>元素只包含http://协议,但没有有效的主机名;因此,服务调出政策会失败,并显示以下错误:Execution of ServiceCallout ExecuteGeocodingRequest failed. Reason: Host not reachable。
解决方法
确保失败的服务调出政策中的 <URL> 元素包含具有可访问的主机名的有效网址。
如需更正上方显示的服务调出政策,您可以修改 <URL> 元素以指定有效的网址:
<?xml version="1.0" encoding="UTF-8&quo>t<; standalone="yes"?
ServiceCallout >name=<"ExecuteGeocodingRequest"
> R<equest v>ariable="Geo<codingReq>uest&<quot;/
ResponseG>eocodingR<esp>onse/Response
HTTPTargetConnection
U<RLht>tp://<maps.googleapis.com/m>a<ps/api/geocode/>json/URL
/HTTPTargetConnection
/ServiceCallout
原因:后端服务器错误
后端服务器返回 4XX 或 5XX 错误响应。
诊断
确定导致错误的服务调出政策。错误响应的
faultstring元素中会显示政策名称。例如,在以下faultstring中,失败的服务调出政策名称是ExecuteGeocodingRequest。"faultstring": "ServiceCallout[ExecuteGeocodingRequest]检查错误响应正文中的
faultstring,并检查Reason中是否列出了任何 4XX 或 5XX 响应代码。例如,以下 faultstring 明确表示从后端服务器返回了响应代码 502:"faultstring": "Execution of ServiceCallout ExecuteGeocodingRequest failed. Reason: ResponseCode 502 is treated as error"
解决方法
确定错误响应代码后,您可以像解决任何 4XX 或 5XX 错误一样解决此问题。如需了解如何排查和解决 4XX 或 5XX 错误的说明,请参阅运行时错误 (4XX/5XX) playbook。