我创建了一个调用后端SOAP服务的JSON REST API。我的问题是API将请求转发为HTTP GET,并且不考虑PayloadFactory构建的SOAP消息。
以下是API配置:
<metadata xmlns="http://www.wso2.org/governance/metadata">
<overview>
<redirectURL/>
<sandboxURL/>
<environments>Production and Sandbox</environments>
<contextTemplate>/bmc/{version}</contextTemplate>
<description/>
<productionTps/>
<visibleRoles/>
<technicalOwner/>
<faultSequence/>
<wsdl/>
<subscriptionAvailability/>
<isLatest>true</isLatest>
<tier>Unlimited</tier>
<provider>admin</provider>
<endpointConfig>{"production_endpoints":{"url":"https://server1.domain.se:8080/arsys/services/ARService?server=server1&webService=SEB:CMDB_BaseElement","config":null},"sandbox_endpoints":{"url":"https://server1.domain.se:8080/arsys/services/ARService?server=server1&webService=SEB:CMDB_BaseElement","config":null},"implementation_status":"managed","endpoint_type":"http"}</endpointConfig>
<endpointURL/>
<inSequence>BMCSystemJsonToSoapSeq</inSequence>
<context>/bmc/1.0</context>
<sandboxTps/>
<endpointSecured>false</endpointSecured>
<versionType>context</versionType>
<endpointAuthDigest>false</endpointAuthDigest>
<tenants/>
<thumbnail/>
<endpointPpassword/>
<advertiseOnly>false</advertiseOnly>
<visibility>public</visibility>
<wadl/>
<technicalOwnerEmail/>
<implementation>ENDPOINT</implementation>
<outSequence>BMCSystemJsonToSoapSeq</outSequence>
<businessOwnerEmail/>
<version>1.0</version>
<apiOwner/>
<transports>http,https</transports>
<visibleTenants/>
<cacheTimeout>300</cacheTimeout>
<isDefaultVersion>false</isDefaultVersion>
<name>BMC</name>
<destinationStatsEnabled>Disabled</destinationStatsEnabled>
<endpointUsername/>
<responseCaching>Disabled</responseCaching>
<businessOwner/>
<status>PUBLISHED</status>
</overview>
<URITemplate>
<authType0>Any</authType0>
<urlPattern0>/system/{name}</urlPattern0>
<httpVerb0>GET</httpVerb0>
</URITemplate>
</metadata>
我的BMCSystemJsonToSoapSeq按顺序生成SOAP消息,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="BMCSystemJsonToSoapSeq" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<payloadFactory media-type="xml">
<format>
<urn:GetList xmlns:urn="urn:SEB:CMDB_BaseElement">
<urn:Qualification>CITag="$1" AND DatasetId="BMC.Asset"</urn:Qualification>
</urn:GetList>
</format>
<args>
<arg evaluator="json" expression="get-property('uri.var.name')"/>
</args>
</payloadFactory>
<header scope="default">
<urn:AuthenticationInfo xmlns:urn="urn:SEB:CMDB_BaseElement">
<urn:userName>usr1</urn:userName>
<urn:password>pwd1</urn:password>
</urn:AuthenticationInfo>
</header>
<property name="messageType" scope="default" type="STRING" value="application/soap+xml"/>
</sequence>
查看电汇日志:
TID: [-1] [] [2016-03-31 13:56:33,345] DEBUG {org.apache.synapse.transport.http.wire} - >> "GET /bmc/1.0/system/191 HTTP/1.1[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,345] DEBUG {org.apache.synapse.transport.http.wire} - >> "Host: localhost:8280[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,345] DEBUG {org.apache.synapse.transport.http.wire} - >> "Connection: keep-alive[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,345] DEBUG {org.apache.synapse.transport.http.wire} - >> "Accept: application/json[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,345] DEBUG {org.apache.synapse.transport.http.wire} - >> "Authorization: Bearer c6a72ffae28c149aef71bd43021067d3[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,345] DEBUG {org.apache.synapse.transport.http.wire} - >> "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,345] DEBUG {org.apache.synapse.transport.http.wire} - >> "Accept-Encoding: gzip, deflate, sdch[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,345] DEBUG {org.apache.synapse.transport.http.wire} - >> "Accept-Language: sv-SE,sv;q=0.8,en-US;q=0.6,en;q=0.4[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,345] DEBUG {org.apache.synapse.transport.http.wire} - >> "Cookie: region3_registry_menu=visible; menuPanel=visible; menuPanelType=main; region1_configure_menu=none; region4_monitor_menu=none; region5_tools_menu=none; MSG14594153721760.42895910477604415=true; MSG14594154045450.30055989572537245=true; requestedURI="../../carbon/resources/resource.jsp?region=region3&item=resource_browser_menu&path=/"; current-breadcrumb=registry_menu%2Cresource_browser_menu%23[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,345] DEBUG {org.apache.synapse.transport.http.wire} - >> "[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,448] DEBUG {org.apache.synapse.transport.http.wire} - << "GET /arsys/services/ARService?server=server1&webService=SEB:CMDB_BaseElement/system/191 HTTP/1.1[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,448] DEBUG {org.apache.synapse.transport.http.wire} - << "Cookie: region3_registry_menu=visible; menuPanel=visible; menuPanelType=main; region1_configure_menu=none; region4_monitor_menu=none; region5_tools_menu=none; MSG14594153721760.42895910477604415=true; MSG14594154045450.30055989572537245=true; requestedURI="../../carbon/resources/resource.jsp?region=region3&item=resource_browser_menu&path=/"; current-breadcrumb=registry_menu%2Cresource_browser_menu%23[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,448] DEBUG {org.apache.synapse.transport.http.wire} - << "Accept: application/json[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,448] DEBUG {org.apache.synapse.transport.http.wire} - << "Accept-Encoding: gzip, deflate, sdch[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,464] DEBUG {org.apache.synapse.transport.http.wire} - << "Accept-Language: sv-SE,sv;q=0.8,en-US;q=0.6,en;q=0.4[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,464] DEBUG {org.apache.synapse.transport.http.wire} - << "Host: server.domain.se:8080[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,464] DEBUG {org.apache.synapse.transport.http.wire} - << "Connection: Keep-Alive[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,464] DEBUG {org.apache.synapse.transport.http.wire} - << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,464] DEBUG {org.apache.synapse.transport.http.wire} - << "[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,464] DEBUG {org.apache.synapse.transport.http.wire} - >> "HTTP/1.1 200 OK[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,464] DEBUG {org.apache.synapse.transport.http.wire} - >> "Server: Apache-Coyote/1.1[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,464] DEBUG {org.apache.synapse.transport.http.wire} - >> "Cache-Control: private[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,464] DEBUG {org.apache.synapse.transport.http.wire} - >> "Expires: Thu, 01 Jan 1970 01:00:00 CET[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,464] DEBUG {org.apache.synapse.transport.http.wire} - >> "Content-Type: text/html;charset=utf-8[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,464] DEBUG {org.apache.synapse.transport.http.wire} - >> "Content-Length: 133[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,464] DEBUG {org.apache.synapse.transport.http.wire} - >> "Date: Thu, 31 Mar 2016 11:56:33 GMT[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,464] DEBUG {org.apache.synapse.transport.http.wire} - >> "[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,464] DEBUG {org.apache.synapse.transport.http.wire} - >> "<h1>ARService</h1>[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,464] DEBUG {org.apache.synapse.transport.http.wire} - >> "<p>Hi there, this is an AXIS service!</p>[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2016-03-31 13:56:33,464] DEBUG {org.apache.synapse.transport.http.wire} - >> "<i>Perhaps there will be a form for invoking the service here...</i>[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1234] [] [2016-03-31 13:56:33,464] ERROR {org.apache.synapse.util.xpath.SynapseJsonPath} - #stringValueOf. Error evaluating JSON Path <$.get-property('uri.var.name')>. Returning empty result. Error>>> invalid path {org.apache.synapse.util.xpath.SynapseJsonPath}
第1期
对API的初始调用如下所示:
curl -X GET --header "Accept: application/xml" --header "Authorization: Bearer TOKEN" "https://172.28.210.192:8243/bmc/1.0/system/191"
因此,由于某种原因,API请求后端服务:
https://server1.domain.se:8080/arsys/services/ARService?server=server1&webService=SEB:CMDB_BaseElement/system/191
第2期
由于某些原因,无法访问我的API请求参数:
TID: [-1234] [] [2016-03-31 13:56:33,464] ERROR {org.apache.synapse.util.xpath.SynapseJsonPath} - #stringValueOf. Error evaluating JSON Path <$.get-property('uri.var.name')>. Returning empty result. Error>>> invalid path {org.apache.synapse.util.xpath.SynapseJsonPath}
有什么想法吗?
答案 0 :(得分:1)
从HTTP端点更改为地址端点并且工作正常。