我有一个关于JAX-WS的web服务,当我从网上请求时,webservice工作正常但是当我从android请求时,服务返回null。
这是WSDL
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="address_example" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="address_example" name="Gate">
<types>
<xsd:schema>
<xsd:import namespace="http://jaxb.dev.java.net/array" schemaLocation="address_example:4225/MobilePlatea/Gate?xsd=1"/>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="address_example" schemaLocation="address_example:4225/MobilePlatea/Gate?xsd=2"/>
</xsd:schema>
</types>
<message name="addUser">
<part name="parameters" element="tns:addUser"/>
</message>
<message name="addUserResponse">
<part name="parameters" element="tns:addUserResponse"/>
</message>
<message name="login">
<part name="parameters" element="tns:login"/>
</message>
<message name="loginResponse">
<part name="parameters" element="tns:loginResponse"/>
</message>
<message name="updatePasswd">
<part name="parameters" element="tns:updatePasswd"/>
</message>
<message name="updatePasswdResponse">
<part name="parameters" element="tns:updatePasswdResponse"/>
</message>
<message name="updUser">
<part name="parameters" element="tns:updUser"/>
</message>
<message name="updUserResponse">
<part name="parameters" element="tns:updUserResponse"/>
</message>
<message name="searchbyCoord">
<part name="parameters" element="tns:searchbyCoord"/>
</message>
<message name="searchbyCoordResponse">
<part name="parameters" element="tns:searchbyCoordResponse"/>
</message>
<message name="add_item">
<part name="parameters" element="tns:add_item"/>
</message>
<message name="add_itemResponse">
<part name="parameters" element="tns:add_itemResponse"/>
</message>
<message name="findByPosition">
<part name="parameters" element="tns:findByPosition"/>
</message>
<message name="findByPositionResponse">
<part name="parameters" element="tns:findByPositionResponse"/>
</message>
<message name="searchTops">
<part name="parameters" element="tns:searchTops"/>
</message>
<message name="searchTopsResponse">
<part name="parameters" element="tns:searchTopsResponse"/>
</message>
<message name="getProdinfo">
<part name="parameters" element="tns:getProdinfo"/>
</message>
<message name="getProdinfoResponse">
<part name="parameters" element="tns:getProdinfoResponse"/>
</message>
<message name="getProdRelated">
<part name="parameters" element="tns:getProdRelated"/>
</message>
<message name="getProdRelatedResponse">
<part name="parameters" element="tns:getProdRelatedResponse"/>
</message>
<message name="getProdImg">
<part name="parameters" element="tns:getProdImg"/>
</message>
<message name="getProdImgResponse">
<part name="parameters" element="tns:getProdImgResponse"/>
</message>
<message name="infoUserSel">
<part name="parameters" element="tns:infoUserSel"/>
</message>
<message name="infoUserSelResponse">
<part name="parameters" element="tns:infoUserSelResponse"/>
</message>
<message name="getInfoSearch">
<part name="parameters" element="tns:getInfoSearch"/>
</message>
<message name="getInfoSearchResponse">
<part name="parameters" element="tns:getInfoSearchResponse"/>
</message>
<portType name="Gate">
<operation name="addUser">
<input wsam:Action="address_exampleGate/addUserRequest" message="tns:addUser"/>
<output wsam:Action="address_exampleGate/addUserResponse" message="tns:addUserResponse"/>
</operation>
<operation name="login">
<input wsam:Action="address_exampleGate/loginRequest" message="tns:login"/>
<output wsam:Action="address_exampleGate/loginResponse" message="tns:loginResponse"/>
</operation>
<operation name="updatePasswd">
<input wsam:Action="address_exampleGate/updatePasswdRequest" message="tns:updatePasswd"/>
<output wsam:Action="address_exampleGate/updatePasswdResponse" message="tns:updatePasswdResponse"/>
</operation>
<operation name="updUser">
<input wsam:Action="address_exampleGate/updUserRequest" message="tns:updUser"/>
<output wsam:Action="address_exampleGate/updUserResponse" message="tns:updUserResponse"/>
</operation>
<operation name="searchbyCoord">
<input wsam:Action="address_exampleGate/searchbyCoordRequest" message="tns:searchbyCoord"/>
<output wsam:Action="address_exampleGate/searchbyCoordResponse" message="tns:searchbyCoordResponse"/>
</operation>
<operation name="add_item">
<input wsam:Action="address_exampleGate/add_itemRequest" message="tns:add_item"/>
<output wsam:Action="address_exampleGate/add_itemResponse" message="tns:add_itemResponse"/>
</operation>
<operation name="findByPosition">
<input wsam:Action="address_exampleGate/findByPositionRequest" message="tns:findByPosition"/>
<output wsam:Action="address_exampleGate/findByPositionResponse" message="tns:findByPositionResponse"/>
</operation>
<operation name="searchTops">
<input wsam:Action="address_exampleGate/searchTopsRequest" message="tns:searchTops"/>
<output wsam:Action="address_exampleGate/searchTopsResponse" message="tns:searchTopsResponse"/>
</operation>
<operation name="getProdinfo">
<input wsam:Action="address_exampleGate/getProdinfoRequest" message="tns:getProdinfo"/>
<output wsam:Action="address_exampleGate/getProdinfoResponse" message="tns:getProdinfoResponse"/>
</operation>
<operation name="getProdRelated">
<input wsam:Action="address_exampleGate/getProdRelatedRequest" message="tns:getProdRelated"/>
<output wsam:Action="address_exampleGate/getProdRelatedResponse" message="tns:getProdRelatedResponse"/>
</operation>
<operation name="getProdImg">
<input wsam:Action="address_exampleGate/getProdImgRequest" message="tns:getProdImg"/>
<output wsam:Action="address_exampleGate/getProdImgResponse" message="tns:getProdImgResponse"/>
</operation>
<operation name="infoUserSel">
<input wsam:Action="address_exampleGate/infoUserSelRequest" message="tns:infoUserSel"/>
<output wsam:Action="address_exampleGate/infoUserSelResponse" message="tns:infoUserSelResponse"/>
</operation>
<operation name="getInfoSearch">
<input wsam:Action="address_exampleGate/getInfoSearchRequest" message="tns:getInfoSearch"/>
<output wsam:Action="address_exampleGate/getInfoSearchResponse" message="tns:getInfoSearchResponse"/>
</operation>
</portType>
<binding name="GatePortBinding" type="tns:Gate">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="addUser">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="login">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="updatePasswd">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="updUser">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="searchbyCoord">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="add_item">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="findByPosition">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="searchTops">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="getProdinfo">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="getProdRelated">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="getProdImg">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="infoUserSel">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="getInfoSearch">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="Gate">
<port name="GatePort" binding="tns:GatePortBinding">
<soap:address location="address_example:4225/MobilePlatea/Gate"/>
</port>
</service>
</definitions>
这是
的代码public void set_info(){
ObjConexion object = new ObjConexion();
SoapObject request = new SoapObject(object.NameSpace(), "getProdinfo");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
Bundle extras = getIntent().getExtras();
PropertyInfo idPro =new PropertyInfo();
idPro.setName("id");
idPro.setValue(extras.getInt("id"));
idPro.setType(Integer.class);
request.addProperty(idPro);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(object.Url());
androidHttpTransport.debug = true;
try {
androidHttpTransport.call("getProdinfo", envelope);
SoapPrimitive result = (SoapPrimitive)envelope.bodyIn;//this is null
}catch (Exception e) {
e.printStackTrace();
Toast.makeText(this,e.getMessage().toString(),Toast.LENGTH_LONG).show();
}
setImages();
}
答案 0 :(得分:0)
问题在于PropertyInfo的setValue我将值放在整数上,显然必须在String上。
希望对某人有所帮助!