wso2ei - 6.1.1 - Axis2Sender在发送消息时出现意外错误

时间:2018-05-28 18:05:38

标签: wsdl wso2ei

当我尝试从wso2ei向我的网络服务发送肥皂请求时出现此错误:

如果我直接打电话给代理或网络服务,一切都很好,接缝是发送调解员的东西,但我无法弄明白!即使我更改代码以通过端点直接调用Web服务,错误也是相同的。

[2018-05-28 14:39:34,150] [EI-Core] ERROR - Axis2Sender Unexpected error during sending message out
org.apache.axis2.AxisFault: The system cannot infer the transport information from the /helloworld URL.
    at org.apache.axis2.description.ClientUtils.inferOutTransport(ClientUtils.java:81)
    at org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.executeImpl(DynamicAxisOperation.java:115)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
    at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:595)
    at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:83)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:548)
    at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:382)
    at org.apache.synapse.endpoints.WSDLEndpoint.send(WSDLEndpoint.java:75)
    at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:121)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:59)
    at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
    at org.apache.synapse.rest.Resource.process(Resource.java:343)
    at org.apache.synapse.rest.API.process(API.java:399)
    at org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:123)
    at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:101)
    at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:69)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:304)
    at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:78)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
    at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:326)
    at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:372)
    at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:151)
    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

这是我的代码:

<?xml version="1.0" encoding="UTF-8"?>
<api context="/helloworld" name="HelloWorldAPI" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="POST">
        <inSequence>
            <property description="createName" expression="json-eval($.name)" name="name" scope="default" type="STRING"/>
            <log description="requestLog" level="custom">
                <property expression="fn:concat(&quot;User name: &quot;,get-property(&quot;name&quot;))" name="message"/>
            </log>
            <payloadFactory description="convertToSoap" media-type="xml">
                <format>
                    <hel:GreetingRequest xmlns:hel="http://qualicorp.com.br/ws/HelloWorldWS/">
                        <hel:name>$1</hel:name>
                    </hel:GreetingRequest>
                </format>
                <args>
                    <arg evaluator="xml" expression="get-property(&quot;name&quot;)"/>
                </args>
            </payloadFactory>

            <property name="ContentType" value="application/xml" scope="axis2"/>
            <property name="HTTP_METHOD" value="POST" scope="axis2" />  

            <log description="requestSoapLog">
                <property name="message" value="Sending request to Proxy"/>
            </log>
            <send>
                <endpoint>
                    <wsdl port="GreetingProxyHttpSoap11Endpoint" service="GreetingProxy" uri="http://localhost:8280/services/GreetingProxy?wsdl"/>
                </endpoint>
            </send>
        </inSequence>
        <outSequence>
            <property name="ContentType" value="application/json" scope="axis2"/>
            <log description="responseLog"/>
            <send/>
        </outSequence>
        <faultSequence>
            <log description="ErrorLog"/>
        </faultSequence>
    </resource>
</api>

<?xml version="1.0" encoding="UTF-8"?>
<proxy name="GreetingProxy" startOnLoad="true" transports="https,http" xmlns="http://ws.apache.org/ns/synapse">
    <target>
        <endpoint name="endpoint_urn_uuid_1FF78996948B9A0B6E14565751214774-1218279313">
            <wsdl port="GreetingPortSoap11" service="GreetingPortService" uri="http://localhost:8080/HelloWorldWS/ws/greeting.wsdl"/>
        </endpoint>
        <inSequence>
            <log description="requestLog">
                <property name="message" value="Sending request"/>
            </log>
        </inSequence>
        <outSequence>
            <log description="responseLog">
                <property name="message" value="&quot;Returning web service&quot;"/>
            </log>
            <send/>
        </outSequence>
        <faultSequence>
            <log description="ErrorLog"/>
        </faultSequence>
    </target>
</proxy>

2 个答案:

答案 0 :(得分:0)

我刚刚发现了一些有趣的行为。如果我通过地址端点更改 wsdl-endpoint ,则API可以正常运行。我添加了一个payloadFactory来创建restResponse和一些日志。

我还不知道为什么 wsdl-endpoint 不起作用或我应该改变它以使其有效。

<?xml version="1.0" encoding="UTF-8"?>
<api context="/helloworld" name="HelloWorldAPI" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="POST">
        <inSequence>
            <property description="createName" expression="json-eval($.name)" name="name" scope="default" type="STRING"/>
            <log description="requestLog" level="custom">
                <property expression="fn:concat(&quot;Nome do usuario recebido: &quot;,get-property(&quot;name&quot;))" name="message"/>
            </log>
            <payloadFactory description="convertToSoap" media-type="xml">
                <format>
                    <hel:GreetingRequest xmlns:hel="http://qualicorp.com.br/ws/HelloWorldWS/">
                        <hel:name>$1</hel:name>
                    </hel:GreetingRequest>
                </format>
                <args>
                    <arg evaluator="xml" expression="get-property(&quot;name&quot;)"/>
                </args>
            </payloadFactory>
            <property name="ContentType" scope="axis2" type="STRING" value="application/xml"/>
            <property name="HTTP_METHOD" scope="axis2" type="STRING" value="POST"/>
            <log description="requestSoapLog">
                <property name="message" value="Enviando requisicao ao Proxy"/>
            </log>
            <send>
                <endpoint>
                    <address uri="http://localhost:8280/services/GreetingProxy?wsdl"/>
                </endpoint>
            </send>
        </inSequence>
        <outSequence>
            <payloadFactory description="convertToSoap" media-type="json">
                <format>
                    {
                        greeting: "$1"
                    }
                </format>
                <args>
                    <arg evaluator="xml" expression="//ns2:greeting/ns2:message/text()" xmlns:ns2="http://qualicorp.com.br/ws/HelloWorldWS/"/>
                </args>
            </payloadFactory>
            <property name="ContentType" scope="axis2" type="STRING" value="application/json"/>
            <log description="responseLog"/>
            <send/>
        </outSequence>
        <faultSequence>
            <log description="ErrorLog"/>
        </faultSequence>
    </resource>
</api>

<?xml version="1.0" encoding="UTF-8"?>
<proxy name="GreetingProxy" startOnLoad="true" transports="https http" xmlns="http://ws.apache.org/ns/synapse">
    <target>
        <endpoint name="endpoint_urn_uuid_1FF78996948B9A0B6E14565751214774-1218279313">
            <wsdl port="GreetingPortSoap11" service="GreetingPortService" uri="http://localhost:8080/HelloWorldWS/ws/greeting.wsdl"/>
        </endpoint>
        <inSequence>
            <log description="requestLog">
                <property name="message" value="Recebendo requisicao"/>
            </log>
        </inSequence>
        <outSequence>
            <log description="responseLog">
                <property name="message" value="&quot;Retorno do web service&quot;"/>
            </log>
            <log description="responseXmlLog" level="custom">
                <property expression="//ns2:greeting" name="message" xmlns:ns2="http://qualicorp.com.br/ws/HelloWorldWS/"/>
            </log>
            <send/>
        </outSequence>
        <faultSequence>
            <log description="ErrorLog"/>
        </faultSequence>
    </target>
</proxy>

答案 1 :(得分:0)

我想我找到了一些东西。如果我直接将它发送到tomcat的Web服务器,我可以使用 wsdl-endpoint 标记,如果我通过wso2的代理访问我的Web服务, address-endpoint 必须是选择。

我没有任何解释为什么,但到目前为止这是wso2的行为。