Problem: modtage et string array fra en apache tomcat webservice
Hej kloge folkVi har et stort problem:
Vi skal kommunikere med en webservice der ligger på en apaache tomcat 5.0 webserver, som er skrevet i java.
Vi skal lave en webklient i asp.net (c#) på en IIS.
Vi kan sagtens kommunikere med den og modtage f.eks. en simpel string eller et objekt. Problemet er at vi skal sende og modtage arrays af typen string. asp.net melder fejl når websiden startes.
her er koden der returnerer arrayet på webservicen:
public class TestService
{
public String[] GetTankNamezString()
{
String[] array2;
array2 = new String[10];
String temp = "";
for (int i=0; i<10; i++)
{
temp = "Tank"+i;
array2[i]=temp;
}
return array2;
}
og her er koden til webklienten der modtager arrayet:
WebApplicationTest.TestServiceRef.TestServiceService ServiceObj = new WebApplicationTest.TestServiceRef.TestServiceService();
WebApplicationTest.TestServiceRef.TestClassStub TCObj =
new WebApplicationTest.TestServiceRef.TestClassStub();
System.Collections.IEnumerator myEnumerator = ServiceObj.GetTankNamezString().GetEnumerator();
while ( myEnumerator.MoveNext())
{ ListTank.Items.Add(myEnumerator.Current.ToString());
}
Til at deploye vores java webservice bruger vi denne WSDD fil:
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="TestService" provider="java:RPC">
<parameter name="className" value="TestService"/>
<parameter name="allowedMethods" value="*"/>
</service>
</deployment>
og WSDL filen:
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="http://localhost:8080/axis/services/TestService" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://localhost:8080/axis/services/TestService" xmlns:intf="http://localhost:8080/axis/services/TestService" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <!--
WSDL created by Apache Axis version: 1.2RC2
Built on Nov 16, 2004 (12:19:44 EST)
-->
- <wsdl:types>
- <schema targetNamespace="http://localhost:8080/axis/services/TestService" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
- <complexType name="ArrayOf_soapenc_string">
- <complexContent>
- <restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="soapenc:string[]" />
</restriction>
</complexContent>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="GetTankNamezStringRequest" />
- <wsdl:message name="GetTankNamezStringResponse">
<wsdl:part name="GetTankNamezStringReturn" type="impl:ArrayOf_soapenc_string" />
</wsdl:message>
- <wsdl:portType name="TestService">
- <wsdl:operation name="GetTankNamezString">
<wsdl:input message="impl:GetTankNamezStringRequest" name="GetTankNamezStringRequest" />
<wsdl:output message="impl:GetTankNamezStringResponse" name="GetTankNamezStringResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="TestServiceSoapBinding" type="impl:TestService">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="GetTankNamezString">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="GetTankNamezStringRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace" use="encoded" />
</wsdl:input>
- <wsdl:output name="GetTankNamezStringResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/axis/services/TestService" use="encoded" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="TestServiceService">
- <wsdl:port binding="impl:TestServiceSoapBinding" name="TestService">
<wsdlsoap:address location="http://localhost:8080/axis/services/TestService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Håber der er nogen der ved hvad vi har lavet galt...
Der skal lige pointeres at der jo ikke er noget galt med webservicen...den kører i hvert fald og vi kan sende og modtage simple strings. det er arrays der er problemet.
på forhånd tak
