axis 2 Web 服务:http 绑定的空参数问题
我正在尝试使用 axis2 开发一个网络服务。问题是我没有获取 http 绑定的 url 中传递的参数。
这是我的 service.xml :
<parameter name="ServiceClass">my.package.MyClass
</parameter>
<operation name="getUser">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
<parameter name="useOriginalwsdl">true</parameter>
这是我的简化 wsdl :
<definitions ...>
<types>
<schema ...>
<complexType name="User">
<sequence>
<element name="id" type="string"/>
<element name="age" type="int"/>
</sequence>
</complexType>
<element name="getUser">
<complexType>
<sequence>
<element name="id" type="xs:string" form="unqualified" />
</sequence>
</complexType>
</element>
<element name="getUserResponse">
<complexType>
<sequence>
<element name="user" nillable="true"
type="user" />
</sequence>
</complexType>
</element>
</schema>
</types>
<message name="getUserRequest">
<part name="parameters" element="getUser" />
</message>
<message name="getUserResponse">
<part name="parameters" element="getUserResponse" />
</message>
<portType name="testPortType">
<operation name="getUser">
<input message="getUserRequest"
Action="urn:getUser" />
<output message="getUserResponse"
Action="urn:getUserResponse" />
</operation>
</portType>
<binding name="testHttpBinding" type="testPortType">
<binding verb="GET" />
<operation name="getUser">
<http:operation location="getUser" />
<input>
<http:urlEncoded />
<input>
<output>
<mime:content type="text/xml" />
</output>
</operation>
</binding>
<service name="test">
<port name="testHttpEndpoint" binding="testHttpBinding">
<address
location="http://localhost:8080/axis2/services/test.testHttpEndpoint/" />
</port>
</service>
</definitions>
最后是 my.package.MyClass :
public final class MyClass {
public User getUser(String id) {
//Do something
}
}
当我使用请求 http://urlToService/getUser?id=test,我输入getUser(String id)但id为空。
有人知道我该如何解决这个问题吗?
谢谢
I am trying to develop a web service with axis2. The problem is that I don't get the parameters passed in the url for an http Binding.
Here is my service.xml :
<parameter name="ServiceClass">my.package.MyClass
</parameter>
<operation name="getUser">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
<parameter name="useOriginalwsdl">true</parameter>
Here is my simplified wsdl :
<definitions ...>
<types>
<schema ...>
<complexType name="User">
<sequence>
<element name="id" type="string"/>
<element name="age" type="int"/>
</sequence>
</complexType>
<element name="getUser">
<complexType>
<sequence>
<element name="id" type="xs:string" form="unqualified" />
</sequence>
</complexType>
</element>
<element name="getUserResponse">
<complexType>
<sequence>
<element name="user" nillable="true"
type="user" />
</sequence>
</complexType>
</element>
</schema>
</types>
<message name="getUserRequest">
<part name="parameters" element="getUser" />
</message>
<message name="getUserResponse">
<part name="parameters" element="getUserResponse" />
</message>
<portType name="testPortType">
<operation name="getUser">
<input message="getUserRequest"
Action="urn:getUser" />
<output message="getUserResponse"
Action="urn:getUserResponse" />
</operation>
</portType>
<binding name="testHttpBinding" type="testPortType">
<binding verb="GET" />
<operation name="getUser">
<http:operation location="getUser" />
<input>
<http:urlEncoded />
<input>
<output>
<mime:content type="text/xml" />
</output>
</operation>
</binding>
<service name="test">
<port name="testHttpEndpoint" binding="testHttpBinding">
<address
location="http://localhost:8080/axis2/services/test.testHttpEndpoint/" />
</port>
</service>
</definitions>
and finally my.package.MyClass :
public final class MyClass {
public User getUser(String id) {
//Do something
}
}
When I call the service with the request http://urlToService/getUser?id=test, I enter in getUser(String id) but the id is null.
Does someone know how am I supposed to fix that?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实上我做错了什么。
在 MyClass 中,我不应该这样做 :
,而是
按照 wsdl 文件中所写的那样。
In fact I was doing something wrong.
In MyClass, I am not supposed to do :
but
as written in the wsdl file.