You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Hughes, Stan" <Th...@nov.com> on 2006/02/15 21:22:32 UTC

Return string[] elements split on spaces

First of all, I am new at this - so, I apologize if this is stupid....

 

I have a web service that returns a simple list of strings. The
implementing function is:

 

    public java.lang.String[] getProductIDsByBrand(java.lang.String
brand) throws java.rmi.RemoteException {

        String[] arr = new String[10];

        arr[0] = "String 1";

        arr[1] = "String 2";

        arr[2] = "String 3";

        arr[3] = "String 4";

        arr[4] = "String 5";

        arr[5] = "String 6";

        arr[6] = "String 7";

        arr[7] = "String 8";

        arr[8] = "String 9";

        arr[9] = "String 10";

        return arr;

    }

 

When my client gets the response, each element is split at the space
character, which gives me a total of 20 elements in the returned
array...

 

Is there some way I can avoid this?

 

My wsdl is:

 

<?xml version="1.0" encoding="UTF-8"?>

<definitions name="TCEServices"
targetNamespace="http://www.nov.com/cetg/services/V1.0"
xmlns:tns="http://www.nov.com/cetg/services/V1.0"
xmlns:typens="http://www.nov.com/cetg/services/V1.0"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/">             

             

      <types>

          <xsd:schema
targetNamespace="http://www.nov.com/cetg/services/V1.0"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">

            <xsd:complexType name="documentInfo">

          <xsd:all>

                <xsd:element name="ItemID" type="xsd:string"/>

                  <xsd:element name="Name" type="xsd:string"/>

              <xsd:element name="Description" type="xsd:string"/>

              <xsd:element name="Category" type="xsd:string"/>

              <xsd:element name="Type" type="xsd:string"/>

              </xsd:all>

            </xsd:complexType>

              <xsd:simpleType name="arrayOfString">

                  <xsd:list itemType="xsd:string"/>

              </xsd:simpleType>

          </xsd:schema> 

      </types>

 

  <message name="GetDocumentFromItemIDRequest">

    <part name="DocumentID" type="xsd:string"/>

  </message>

  <message name="GetDocumentFromItemIDResponse">

    <part name="DocumentInfo" type="typens:documentInfo"/>

  </message>

    <message name="GetProductIDsByBrandRequest">

    <part name="Brand" type="xsd:string"/>

  </message>

    <message name="GetProductIDsByBrandResponse">

    <part name="ProductIDs" type="typens:arrayOfString"/>

  </message>

    <portType name="TCEServices">

    <operation name="getDocument">

      <input message="tns:GetDocumentFromItemIDRequest"/>

      <output message="tns:GetDocumentFromItemIDResponse"/>

    </operation>

    <operation name="getProductIDsByBrand">

      <input message="typens:GetProductIDsByBrandRequest"/>

      <output message="typens:GetProductIDsByBrandResponse"/>

    </operation>

  </portType>

 

  <binding name="TCEServicesSOAPBinding" type="tns:TCEServices">

    <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>

    <operation name="getDocument">

      <soap:operation soapAction=""/>

      <input>

        <soap:body use="literal"/>

      </input>

      <output>

        <soap:body use="literal"/>

      </output>

    </operation>

    <operation name="getProductIDsByBrand">

      <soap:operation/>

      <input>

              <soap:body use="literal"/>

            </input>

      <output>

              <soap:body use="literal"/>

            </output>

    </operation>

  </binding>

 

  <service name="TCEServicesService">

    <port name="TCEServices" binding="tns:TCEServicesSOAPBinding">

      <soap:address
location="http://localhost:8080/services/services/TCEServices"/>

    </port>

  </service>

      

</definitions>

 


Re: Return string[] elements split on spaces

Posted by robert <ro...@gmail.com>.
Why not just create a collection, and convert the collection to an array? 

 List < String > myList = new ArrayList < String > ();
                myList.add("aaa");
                myList.add("bbb");

String [] myArray = myList.toArray(new
                        String[myList.size()]);

HTH, 
Robert 
http://www.braziloutsource.com/

Em Quarta 15 Fevereiro 2006 18:22, o Hughes, Stan escreveu:
> First of all, I am new at this - so, I apologize if this is stupid....
>
>
>
> I have a web service that returns a simple list of strings. The
> implementing function is:
>
>
>
>     public java.lang.String[] getProductIDsByBrand(java.lang.String
> brand) throws java.rmi.RemoteException {
>
>         String[] arr = new String[10];
>
>         arr[0] = "String 1";
>
>         arr[1] = "String 2";
>
>         arr[2] = "String 3";
>
>         arr[3] = "String 4";
>
>         arr[4] = "String 5";
>
>         arr[5] = "String 6";
>
>         arr[6] = "String 7";
>
>         arr[7] = "String 8";
>
>         arr[8] = "String 9";
>
>         arr[9] = "String 10";
>
>         return arr;
>
>     }
>
>
>
> When my client gets the response, each element is split at the space
> character, which gives me a total of 20 elements in the returned
> array...
>
>
>
> Is there some way I can avoid this?
>
>
>
> My wsdl is:
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <definitions name="TCEServices"
> targetNamespace="http://www.nov.com/cetg/services/V1.0"
> xmlns:tns="http://www.nov.com/cetg/services/V1.0"
> xmlns:typens="http://www.nov.com/cetg/services/V1.0"
> xmlns:xsd="http://www.w3.org/1999/XMLSchema"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns="http://schemas.xmlsoap.org/wsdl/">
>
>
>
>       <types>
>
>           <xsd:schema
> targetNamespace="http://www.nov.com/cetg/services/V1.0"
> xmlns:xsd="http://www.w3.org/1999/XMLSchema">
>
>             <xsd:complexType name="documentInfo">
>
>           <xsd:all>
>
>                 <xsd:element name="ItemID" type="xsd:string"/>
>
>                   <xsd:element name="Name" type="xsd:string"/>
>
>               <xsd:element name="Description" type="xsd:string"/>
>
>               <xsd:element name="Category" type="xsd:string"/>
>
>               <xsd:element name="Type" type="xsd:string"/>
>
>               </xsd:all>
>
>             </xsd:complexType>
>
>               <xsd:simpleType name="arrayOfString">
>
>                   <xsd:list itemType="xsd:string"/>
>
>               </xsd:simpleType>
>
>           </xsd:schema>
>
>       </types>
>
>
>
>   <message name="GetDocumentFromItemIDRequest">
>
>     <part name="DocumentID" type="xsd:string"/>
>
>   </message>
>
>   <message name="GetDocumentFromItemIDResponse">
>
>     <part name="DocumentInfo" type="typens:documentInfo"/>
>
>   </message>
>
>     <message name="GetProductIDsByBrandRequest">
>
>     <part name="Brand" type="xsd:string"/>
>
>   </message>
>
>     <message name="GetProductIDsByBrandResponse">
>
>     <part name="ProductIDs" type="typens:arrayOfString"/>
>
>   </message>
>
>     <portType name="TCEServices">
>
>     <operation name="getDocument">
>
>       <input message="tns:GetDocumentFromItemIDRequest"/>
>
>       <output message="tns:GetDocumentFromItemIDResponse"/>
>
>     </operation>
>
>     <operation name="getProductIDsByBrand">
>
>       <input message="typens:GetProductIDsByBrandRequest"/>
>
>       <output message="typens:GetProductIDsByBrandResponse"/>
>
>     </operation>
>
>   </portType>
>
>
>
>   <binding name="TCEServicesSOAPBinding" type="tns:TCEServices">
>
>     <soap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http"/>
>
>     <operation name="getDocument">
>
>       <soap:operation soapAction=""/>
>
>       <input>
>
>         <soap:body use="literal"/>
>
>       </input>
>
>       <output>
>
>         <soap:body use="literal"/>
>
>       </output>
>
>     </operation>
>
>     <operation name="getProductIDsByBrand">
>
>       <soap:operation/>
>
>       <input>
>
>               <soap:body use="literal"/>
>
>             </input>
>
>       <output>
>
>               <soap:body use="literal"/>
>
>             </output>
>
>     </operation>
>
>   </binding>
>
>
>
>   <service name="TCEServicesService">
>
>     <port name="TCEServices" binding="tns:TCEServicesSOAPBinding">
>
>       <soap:address
> location="http://localhost:8080/services/services/TCEServices"/>
>
>     </port>
>
>   </service>
>
>
>
> </definitions>

--