如果使用样品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());
}
}
配置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>