私の英語でごめんなさい。私はWebサービスが初めてです。
私は軸のWebサービスを持っています:
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
...
<service name="ServerPt" provider="java:RPC" style="wrapped" use="literal">
...
<operation name="getStop" qname="operNS:getStop" xmlns:operNS="urn:StopServer" returnQName="return" returnType="rtns:Stop" xmlns:rtns="urn:StopServer" >
<parameter qname="id" type="tns:long" xmlns:tns="http://www.w3.org/2001/XMLSchema"/>
</operation>
...
<parameter name="allowedMethods" value="... getStop ..."/>
...
<typeMapping
xmlns:ns="urn:StopServer"
qname="ns:Stop"
type="java:net.fist.st.stops.soap.server.Stop"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
/>
...
</service>
...
</deployment>
そして、Java クライアントからこのサービスにアクセスしたい。これを試す:
public static void main(String[] args)
{
try
{
String endpoint = "http://192.168.0.1:28080/ws/services/ServerPt";
Service s = new Service();
Call c = (Call) s.createCall();
c.setTargetEndpointAddress(endpoint);
c.addParameter("id",org.apache.axis.Constants.XSD_LONG,javax.xml.rpc.ParameterMode.IN);
c.setReturnType(new QName("urn:StopServer", "rtns:Stop"), Stop.class);
c.registerTypeMapping(Stop.class, new QName("urn:StopServer", "rtns:Stop"), new BeanSerializerFactory(Stop.class, new QName("urn:StopServer", "rtns:Stop")), new BeanDeserializerFactory(Stop.class, new QName("urn:StopServer", "rtns:Stop")));
c.setOperation("getStop");
Stop st = (Stop)c.invoke( new Object[] { new Long(295) } );
System.out.println(st.getCode().toString());
} catch(Exception e)
{
e.printStackTrace();
}
}
しかし、スローされた例外:
org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
サーバーはリクエストを受け取り、ログファイルには次のように表示されます:
= Elapsed: 117 milliseconds
= In message: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><getStop xmlns=""><arg0 xsi:type="xsd:long">295</arg0></getStop></soapenv:Body></soapenv:Envelope>
= Out message: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><getStopResponse xmlns=""><return><id>295</id><name>Lupe</name><country>GB</country><district> </district><code>250</code><codeInf>094811</codeInf><railCode>25</railCode></return></getStopResponse></soapenv:Body></soapenv:Envelope>
=======================================================
助けてください。