WSO2响应二进制为什么?

时间:2013-06-10 13:40:58

标签: wso2 esb wso2esb

如果使用示例axis2Server服务非常好。但是当我使用javax创建自己的Web服务时,我遇到了一个问题。

我使用了wso2 esb 4.60默认配置

网络服务:

import javax.jws.WebParam;
import javax.jws.WebService;

@WebService
public class Lpu {
    public boolean scheduleAnAppointment(@WebParam(name = "time") Integer time) {
        return true;
    }
}

启动网络服务:

import javax.xml.ws.Endpoint;

public class Server {
    public static void main(String[] args)
    {
        Endpoint.publish("http://localhost:8090/WebServices/lpu", new Lpu());
    }
} 

config esb:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
   <sequence name="main">
      <in>
         <log level="full"/>
         <send>
            <endpoint>
               <address uri="http://localhost:8090/WebServices/lpu"/>
            </endpoint>
         </send>
      </in>
      <out>
         <log level="full"/>
         <send/>
      </out>
   </sequence>
</definitions>

响应:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <axis2ns1:binary xmlns:axis2ns1="http://ws.apache.org/commons/ns/payload">PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxTOkVudmVsb3BlIHhtbG5zOlM9Imh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3NvYXAvZW52ZWxvcGUvIj48UzpCb2R5PjxuczI6c2NoZWR1bGVBbkFwcG9pbnRtZW50UmVzcG9uc2UgeG1sbnM6bnMyPSJodHRwOi8vZmVyLndlYnNlcnZpY2UvIj48cmV0dXJuPmZhbHNlPC9yZXR1cm4+PC9uczI6c2NoZWR1bGVBbkFwcG9pbnRtZW50UmVzcG9uc2U+PC9TOkJvZHk+PC9TOkVudmVsb3BlPg==</axis2ns1:binary>
   </soapenv:Body>
</soapenv:Envelope>

我想要获得:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:scheduleAnAppointmentResponse xmlns:ns2="http://lpu.webservice/">
         <return>true</return>
      </ns2:scheduleAnAppointmentResponse>
   </S:Body>
</S:Envelope>

我的要求

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fer="http://lpu.webservice/">
   <soapenv:Header/>
   <soapenv:Body>
      <lpu:scheduleAnAppointment>
         <time>12</time>
      </lpu:scheduleAnAppointment>
   </soapenv:Body>
</soapenv:Envelope>

2 个答案:

答案 0 :(得分:1)

ESB 4.6.0与传递传输一起发布,它不会构建消息。因此,如果您在序列中使用日志中介,您将获得二进制响应。但在客户端,您应该以首选格式收到您的回复。

如果切换到NIO传输,在序列中也可以获得实际的消息有效负载。为此,您需要在axis2配置(axis2.conf)

中编辑传输发送方和接收方

答案 1 :(得分:1)

axis2.xml更改为axis2_nhttp.xml  /repository/conf/carbon.xml改变:

<ConfigurationFile>${carbon.home}/repository/conf/axis2/axis2_nhttp.xml</ConfigurationFile>

解密有效载荷的另一个建议:

WSO2 responds payload in binary