깨끗한/더 나은 해결책을 찾았습니다. 위의 답변의 향상된 버전 일뿐입니다.
주요 과제는 프록시 서비스 접근 방식에서 발생하는 것처럼 SOAP WSDL 및 서비스 끝점 (컨텍스트 URI)을 강제로 처리하지 않는 것입니다. contextURI WSO2 팀과 협력하여 (/ services //)을 제안 할 경우 을 사용할 필요가 없습니다. 표준 문서에는 필요한 모든 세부 정보가 있습니다.
논리는 다음과 같습니다
(나는 세 가지로 분할,하지만 당신은뿐만 아니라 하나의 순서로 모든 넣을 수) 3 개 시퀀스를 정의합니다.
주 계열 (내장 한 표준 -이 요청이 이미 ESB에 정의 된 프록시 서비스 규칙을 따르지 않는 경우 모든 트래픽을 얻는 순서입니다). 기본 시퀀스에서 모든 수신 요청을 필터링/조건 라우팅을 수행하는 다른 시퀀스로 라우팅합니다.
<sequence name="main">
<in>
<log level="full"/>
<sequence key="routing_seq"/>
</in>
<out>
<send/>
</out>
<description>The main sequence for the message mediation</description>
</sequence>
* routing_sequence * 그냥 첫 번째 대답에, 우리는 경로에 요청의 컨텍스트 URI에 따라 다른 특별한 순서로 들어오는 요청을 가고있다.
<sequence xmlns="http://ws.apache.org/ns/synapse" name="routing_seq">
<in>
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="Current URL" expression="get-property('To')"/>
</log>
<conditionalRouter continueAfter="false">
<conditionalRoute breakRoute="false" asynchronous="false">
<condition>
<or>
<match type="url" regex="/firstService/10\.06/.*"/>
<match type="url" regex="/firstServiceVariant/.*"/>
</or>
</condition>
<target sequence="firstService_seq"/>
</conditionalRoute>
<conditionalRoute breakRoute="false" asynchronous="false">
<condition>
<match type="url" regex="/secondService.*"/>
</condition>
<target sequence="second_seq"/>
</conditionalRoute>
</conditionalRouter>
</in>
</sequence>
* firstservice_seq *
이제 우리는 들어오는 요청을 처리 할 준비가되어 - 우리가 이전 단계에서 "firstservice"로 응용 프로그램을 식별 있습니다.이 여기에받을 수있는 요청 두 종류의 - 한 WSDL을위한이 그리고 다른 하나는
<sequence xmlns="http://ws.apache.org/ns/synapse" name="firstService_seq">
<in>
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
<!-- We are checking whether the request ends with a ?wsdl or .xsd -->
<!-- For that we are using the context URI present in the 'To' field -->
<!-- if it is a wsdl or xsd request, we are converting it to a HTTP GET method -->
<!-- and sending to the final endpoint. All soap operation requests are sent as HTTP POST -->
<switch xmlns:ns="http://org.apache.synapse/xsd" source="get-property('To')">
<case regex=".*(?:\?[Ww][Ss][Dd][Ll]|\.[Xx][Ss][Dd])\s*$">
<property name="HTTP_METHOD" value="GET"/>
<property name="messageType" value="text/xml"/>
<send receive="wsdl_transformer_seq">
<endpoint key="local-enrty-firstservice-ep-key"/>
</send>
<drop/>
</case>
<!-- default means non-wsdl/non-xsd - which means a regular soap operation on the service -->
<default>
<property name="HTTP_METHOD" value="POST"/>
<send>
<endpoint key="local-enrty-firstservice-ep-key"/>
</send>
</default>
</switch>
</in>
<out>
<send/>
</out>
</sequence>
당신이 순서 정의의 의견을 읽고 희망 비누 요청입니다. 보시다시피, 나는 wsdl 및 xsd 요청을 HTTP GET으로 변환하여 응용 프로그램 계층에서 혼란을 피할 수 있습니다. 그렇지 않으면 약간의 정크 SOAP 본문 부분이 흐름의 어딘가에서 주입 될 수 있습니다.
기본적으로 /firstservice/10.06/service?WSDL (WSDL 요청 인 경우)이나 /firstservice/10.06/service와 같은 컨텍스트 URI가 포함 된 'To'속성을 확인합니다. SOAP 요청 인 경우 . 그 가치에 기초하여 우리는 그 요청을 어떻게 처리 할 것인지를 결정합니다.
참고 WSDL 로직의 아래 부분 : 주소 필드 (정보가 포함되어 있습니다 :
<send receive="wsdl_transformer_seq">
<endpoint key="local-enrty-firstservice-ep-key"/>
</send>
<drop/>
</send>
무슨 일 우리가 (내가 곧 설명 할 것이다) 엔드 포인트에서 WSDL을 끌어 때의 schemaLocation과 비누가 있다는 것입니다 호스트 이름 및 포트)를 표시합니다. 내부 정보를 고객 및 다른 사람들에게 공개 할 때 원하지 않는 결과입니다. 그래서 우리는 그것을 가려 야합니다. 이를 수행하는 방법은 WSO2에서 특별한 기능을 사용하는 것입니다. 보내기에서 이 클라이언트에게 보내기 전에 보내기 결과 인을 수신 할 다른 시퀀스를 지정할 수 있습니다. 순서대로 <out>
부분을 정의하는 것과 같습니다. 이 특정 조작을 모든 요청에 적용하지 않으려면 wsdl/xsd reqeusts에만 적용되는 특수 시퀀스를 정의하지 않습니다. wsdl_transformer_seq에서 우리는 XSLT를 사용하여 wsdl 또는 xsd 응답에있는 호스트 이름과 포트를 변경합니다.
wsdl_transformer_seq
<sequence name="wsdl_transformer_seq">
<xslt xmlns:ns="http://org.apache.synapse/xsd"
key="xslt-url-manipulator"
source="/"/>
<send/>
</sequence>
나는 이러한 항목을 구체화 주 (예를 들어, XSLT 변환기)와 그들 로컬 엔트리 레지스트리를 통해로드되는.
<localEntry key="xslt-url-manipulator"
src="file:repository/myapp/resources/transform/url-in-wsdl-transform.xslt"/>
이제 URL -에 - WSDL-을 Transform.xslt
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
version="2.0">
<xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
<xsl:param name="newURL">https://services.mycompany.com</xsl:param>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="soap:address/@location">
<xsl:attribute name="location">
<xsl:value-of select="replace(.,'https?://[^/]*',$newURL)"/>
</xsl:attribute>
</xsl:template>
<xsl:template match="xs:import/@schemaLocation">
<xsl:attribute name="schemaLocation">
<xsl:value-of select="replace(.,'https?://[^/]*',$newURL)"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
주 이름의 내용 - 위의 XSLT에서 - https://services.mycompany.com. 당신은 당신이 원하는대로로 변경할 수 있고,의 schemaLocation과 비누 :은 WSDL 및 XSD의 주소 필드는 현재 호스트에 그것을 사용 : 항구 지역
그리고 마지막으로 엔드 포인트가 로컬 enrty-firstservice-EP-키 위의 내용은 위의 xslt 항목과 마찬가지로 외부에서로드 된 파일입니다. 그래서 나는 actul 외부 파일의 내용 만 게시 할 것입니다.
이것은 거친 쿠키 였고 WSO2 소스 코드를 파헤쳐 문서화되지 않은 기능을 파악해야했습니다. WSO2 세계에서는 "문서화되지 않은"것이지만, WSO2는 WSO2에 게시되지 않은 많은 기능을 가진 타사 라이브러리를 사용하기 때문에 문서화되어 있습니다. 끝점은 응용 프로그램 계층 인스턴스를 가리키며 라운드 로빈 알고리즘을 사용하여 트래픽을 avilalble 응용 프로그램 계층 인스턴스에 배포합니다. 마법의 많은있다
<endpoint xmlns="http://ws.apache.org/ns/synapse">
<loadbalance algorithm="org.apache.synapse.endpoints.algorithms.RoundRobin">
<endpoint name="firsthost_5012">
<http uri-template="http://firsthost.com:5012{+uri.var.servicepath}"/>
</endpoint>
<endpoint name="firsthost_5022">
<http uri-template="http://firsthost.com:5022{+uri.var.servicepath}"/>
</endpoint>
</loadbalance>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="uri.var.servicepath"
expression="get-property('To')"/>
</endpoint>
여기서 발생 - 먼저 우리가 uri.var라는 특별한 변수에 컨텍스트 URI를 저장합니다.servicepath 이제 WSO 4.7.0부터 사용할 수있는 새로운 "http endpoint"기능을 사용할 것입니다.
http 끝점은 끝점을 동적으로 구성 할 수있는 uri-template을 사용합니다. 그래서 구성 컨텍스트 URI를 지정할 필요가 없습니다 - 그래서 우리가 말을하자 우리가 ESB에있어 원래 요청이 같았다 :
http://esbhost.com:8280/firstservice/10.06/service
URI 여기 문맥은 "/firstservice/10.06입니다/service "- 실제 app-tier 서버 url에이 값을 추가하기를 원합니다. 즉, 내가 되길 원한다. http://firsthost.com:5022/firstservice/10.06/service
http 엔드 포인트에서 이전에 정의한 - uri.var.servicepath 특수 변수를 사용할 수있다.
<http uri-template="http://firsthost.com:5022{+uri.var.servicepath}"/>
uri.var.servicepath에는 처음에 '/'가 이미 있기 때문에 별도로 지정하지 않습니다. 그러나 괄호 안에 + 기호를 적어 두십시오. 저건 뭘위한거야? hmmm - WSO2는 재미있는 제 3 자 라이브러리 인 "좋은 uri 프로세서"를 사용한다는 것이 밝혀졌습니다.이 API는 주로 RESTful API에 사용됩니다. 불행히도이 필드를 평범하게 사용하면 http://firsthost.com:5022 {uri.var.servicepath}와 같이 타사 라이브러리는 URI url에있는 특수 문자를 % 20f 또는 그와 유사한 것으로 안전한 것으로 변환합니다. 그래서 우리의 URL은 이제 http : // firsthost : 5022 % 20ffirstservice % 20f10.06 ....이됩니다. - 좋지 않습니다. 여기에 제 3 자 라이브러리의 특별한 기능이 저장되어 있습니다. 특수 변수의 시작 부분에 +를 입력하면이 번역은 해제됩니다.) - voila - 우리가 원하는 것을 얻었습니다.
그래서 여러분입니다. 나는 그것을 매우 긴 포스트 알고 아래의 전체 구성 (마이너스 위의 섹션에서 찾을 수있는 외부화 항목)
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
<registry provider="org.wso2.carbon.mediation.registry.WSO2Registry">
<parameter name="cachableDuration">15000</parameter>
</registry>
<localEntry key="xslt-url-manipulator"
src="file:repository/myapp/resources/transform/url-in-wsdl-transform.xslt"/>
<localEntry key="local-enrty-firstservice-ep-key"
src="file:repository/myapp/resources/endpoint/firstservice-endpoints.xml">
</localEntry>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="routing_seq">
<in>
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="context URI" expression="get-property('To')"/>
</log>
<conditionalRouter continueAfter="false">
<conditionalRoute breakRoute="false" asynchronous="false">
<condition>
<or>
<match type="url" regex="/firstService/10\.06/.*"/>
<match type="url" regex="/firstServiceVariant/.*"/>
</or>
</condition>
<target sequence="firstService_seq"/>
</conditionalRoute>
<conditionalRoute breakRoute="false" asynchronous="false">
<condition>
<match type="url" regex="/secondService.*"/>
</condition>
<target sequence="second_seq"/>
</conditionalRoute>
</conditionalRouter>
</in>
</sequence>
<sequence name="wsdl_transformer_seq">
<xslt xmlns:ns="http://org.apache.synapse/xsd"
key="xslt-url-manipulator"
source="/"/>
<send/>
</sequence>
<sequence name="fault">
<log level="full">
<property name="MESSAGE" value="Executing default 'fault' sequence"/>
<property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
</log>
<drop/>
</sequence>
<sequence name="firstservice_seq">
<in>
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
<switch xmlns:ns="http://org.apache.synapse/xsd" source="get-property('To')">
<case regex=".*(?:\?[Ww][Ss][Dd][Ll]|\.[Xx][Ss][Dd])\s*$">
<property name="HTTP_METHOD" value="GET"/>
<property name="messageType" value="text/xml"/>
<send receive="wsdl_transformer_seq">
<endpoint key="local-enrty-firstservice-ep-key"/>
</send>
<drop/>
</case>
<default>
<property name="HTTP_METHOD" value="POST"/>
<send>
<endpoint key="local-enrty-firstservice-ep-key"/>
</send>
</default>
</switch>
</in>
</sequence>
<sequence name="main">
<in>
<filter xmlns:ns="http://org.apache.synapse/xsd"
source="get-property('To')"
regex="http://localhost:9000.*">
<then>
<send/>
</then>
<else/>
</filter>
<sequence key="routing_seq"/>
</in>
<out>
<send/>
</out>
<description>The main sequence for the message mediation</description>
</sequence>
</definitions>
를 게시하려고합니다 -하지만 걱정하는 사람들에 대한 세부 사항을 설명하고 싶었다. 누군가가 도움이되기를 바랍니다.
나는 내 자신의 답을 찾기 직전 인 것처럼 보입니다. 변화는 다른 접근법에서 사용할 수있는 많은 기능을 지원하지 않는 접근 방식을 사용하여 ESB 문제를 해결하려고 시도한 것이 었습니다. 프록시 서비스 대신에 시퀀스를 사용해야합니다. WSO2에서는 정규 표현식 기반 URL 처리를 시퀀스에서 제공합니다. 저는 프록시 서비스로 시작하여 문제를 해결하는 방법에 대한 여러 커뮤니티 회원들의 생각과 제안이 있었기 때문에 멈추었습니다. 나는 위의 질문에 별도의 항목으로 대답하려고 노력할 것입니다. 기다려.... –