You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Eric Carlson <er...@group-technical.com> on 2004/03/06 15:32:51 UTC

My java client always returns (null)

Hi,

Sorry for the long post ;-)
I have (honestly!) been trying hard to get as simple a java client
going for a sexy looking webservice I've seen at xmethods but with no
joy. It seems to connect but always returns null. If its ok, I'd like
to show the wsdl and my java sources please? So if anyone has a moment
can they give me a clue why I get null please?

(My SOAPResponse is an attempt at a generic bean to handle responses.
I think the real problem here is my lack of ability to see exactly
which fields in the WSDL should be used for the mapping in my source,
and how ;-)). Thanks very much in advance...)

-- BEGIN WSDL --
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:s0="http://www.webservicex.net/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://www.webservicex.net/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types>
    <s:schema elementFormDefault="qualified"
targetNamespace="http://www.webservicex.net/">
      <s:element name="Translate">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="1" name="LanguageMode"
type="s0:Language" />
            <s:element minOccurs="0" maxOccurs="1" name="Text"
type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:simpleType name="Language">
        <s:restriction base="s:string">
          <s:enumeration value="EnglishTOChinese" />
          <s:enumeration value="EnglishTOFrench" />
          <s:enumeration value="EnglishTOGerman" />
          <s:enumeration value="EnglishTOItalian" />
          <s:enumeration value="EnglishTOJapanese" />
          <s:enumeration value="EnglishTOKorean" />
          <s:enumeration value="EnglishTOPortuguese" />
          <s:enumeration value="EnglishTOSpanish" />
          <s:enumeration value="ChineseTOEnglish" />
          <s:enumeration value="FrenchTOEnglish" />
          <s:enumeration value="FrenchTOGerman" />
          <s:enumeration value="GermanTOEnglish" />
          <s:enumeration value="GermanTOFrench" />
          <s:enumeration value="ItalianTOEnglish" />
          <s:enumeration value="JapaneseTOEnglish" />
          <s:enumeration value="KoreanTOEnglish" />
          <s:enumeration value="PortugueseTOEnglish" />
          <s:enumeration value="RussianTOEnglish" />
          <s:enumeration value="SpanishTOEnglish" />
        </s:restriction>
      </s:simpleType>
      <s:element name="TranslateResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1"
name="TranslateResult" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="string" nillable="true" type="s:string" />
    </s:schema>
  </types>
  <message name="TranslateSoapIn">
    <part name="parameters" element="s0:Translate" />
  </message>
  <message name="TranslateSoapOut">
    <part name="parameters" element="s0:TranslateResponse" />
  </message>
  <message name="TranslateHttpGetIn">
    <part name="LanguageMode" type="s:string" />
    <part name="Text" type="s:string" />
  </message>
  <message name="TranslateHttpGetOut">
    <part name="Body" element="s0:string" />
  </message>
  <message name="TranslateHttpPostIn">
    <part name="LanguageMode" type="s:string" />
    <part name="Text" type="s:string" />
  </message>
  <message name="TranslateHttpPostOut">
    <part name="Body" element="s0:string" />
  </message>
  <portType name="TranslationServiceSoap">
    <operation name="Translate">
      <documentation>Convert text from one language to another
language .Supported languages are English to Chinese, English to
French, English to German, English to Italian, English to Japanese,
English to Korean, English to Portuguese, English to Spanish, Chinese
to English, French to English, French to German, German to English,
German to French, Italian to English, Japanese to English, Korean to
English, Portuguese to English, Russian to English, Spanish to
English.</documentation>
      <input message="s0:TranslateSoapIn" />
      <output message="s0:TranslateSoapOut" />
    </operation>
  </portType>
  <portType name="TranslationServiceHttpGet">
    <operation name="Translate">
      <documentation>Convert text from one language to another
language .Supported languages are English to Chinese, English to
French, English to German, English to Italian, English to Japanese,
English to Korean, English to Portuguese, English to Spanish, Chinese
to English, French to English, French to German, German to English,
German to French, Italian to English, Japanese to English, Korean to
English, Portuguese to English, Russian to English, Spanish to
English.</documentation>
      <input message="s0:TranslateHttpGetIn" />
      <output message="s0:TranslateHttpGetOut" />
    </operation>
  </portType>
  <portType name="TranslationServiceHttpPost">
    <operation name="Translate">
      <documentation>Convert text from one language to another
language .Supported languages are English to Chinese, English to
French, English to German, English to Italian, English to Japanese,
English to Korean, English to Portuguese, English to Spanish, Chinese
to English, French to English, French to German, German to English,
German to French, Italian to English, Japanese to English, Korean to
English, Portuguese to English, Russian to English, Spanish to
English.</documentation>
      <input message="s0:TranslateHttpPostIn" />
      <output message="s0:TranslateHttpPostOut" />
    </operation>
  </portType>
  <binding name="TranslationServiceSoap"
type="s0:TranslationServiceSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
    <operation name="Translate">
      <soap:operation
soapAction="http://www.webservicex.net/Translate" style="document" />
      <input>
        <soap:body use="literal" />
      </input>
      <output>
        <soap:body use="literal" />
      </output>
    </operation>
  </binding>
  <binding name="TranslationServiceHttpGet"
type="s0:TranslationServiceHttpGet">
    <http:binding verb="GET" />
    <operation name="Translate">
      <http:operation location="/Translate" />
      <input>
        <http:urlEncoded />
      </input>
      <output>
        <mime:mimeXml part="Body" />
      </output>
    </operation>
  </binding>
  <binding name="TranslationServiceHttpPost"
type="s0:TranslationServiceHttpPost">
    <http:binding verb="POST" />
    <operation name="Translate">
      <http:operation location="/Translate" />
      <input>
        <mime:content type="application/x-www-form-urlencoded" />
      </input>
      <output>
        <mime:mimeXml part="Body" />
      </output>
    </operation>
  </binding>
  <service name="TranslationService">
    <port name="TranslationServiceSoap"
binding="s0:TranslationServiceSoap">
      <soap:address
location="http://www.webservicex.net/TranslateService.asmx" />
    </port>
    <port name="TranslationServiceHttpGet"
binding="s0:TranslationServiceHttpGet">
      <http:address
location="http://www.webservicex.net/TranslateService.asmx" />
    </port>
    <port name="TranslationServiceHttpPost"
binding="s0:TranslationServiceHttpPost">
      <http:address
location="http://www.webservicex.net/TranslateService.asmx" />
    </port>
  </service>
</definitions>
-- END WSDL--

-- BEGIN Translate.java --
import java.io.*;
import java.util.*;
import java.net.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import javax.xml.parsers.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.encoding.*;
import org.apache.soap.encoding.soapenc.*;
import org.apache.soap.rpc.*;
import org.apache.soap.transport.http.SOAPHTTPConnection;

public class Translate {
    public static void main (String[] args) {
        try {

	    URL url = new
URL("http://www.webservicex.com/TranslateService.asmx");

	    SOAPHTTPConnection st = new SOAPHTTPConnection();

	    Call call = new Call();
            call.setSOAPTransport(st);

            call.setTargetObjectURI("urn:TranslationServiceSOAP");
	    call.setMethodName("Translate");

	    SOAPMappingRegistry smr = new SOAPMappingRegistry();
	    call.setSOAPMappingRegistry(smr);

	    BeanSerializer beanSer = new BeanSerializer();

	    smr.mapTypes(Constants.NS_URI_SOAP_ENC,
              new QName( "http://www.webservicex.net/",
"TranslateResult"),
                  SOAPResponse.class, beanSer, beanSer);

	    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

	    Vector params = new Vector();
            params.addElement (new Parameter("LanguageMode",
String.class, "EnglishTOFrench", null));
            params.addElement (new Parameter("Text", String.class,
"Hello", null));
	    call.setParams(params);

            Response resp = null;
            try {
                resp = call.invoke(url,
"http://www.webservicex.net/Translate");
System.out.println(resp);
	    } catch(Exception e) {
                System.err.println(e.toString());
            }

            Object value = null;

	    if (!resp.generatedFault()) {
                Parameter ret = resp.getReturnValue();
                value = ret.getValue();
            } else {
                Fault fault = resp.getFault();
                System.err.println("SOAP call raised fault code:"
	            +fault.getFaultCode()
                    +" Text:"+ fault.getFaultString());
            }

            System.out.println("Return value is "+value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
-- END Translate.java --

-- BEGIN SOAPResponse.java --
import java.io.*;

public class SOAPResponse {
    public String TranslateResponse;
    public String TranslateResult;
    public String string;

    public String toString() {
        return TranslateResponse;
    }

    public SOAPResponse() {}

    public String getTranslateResponse() {
        return TranslateResponse;
    }

    public void setTranslateResponse(String TranslateResponse) {
        this.TranslateResponse = TranslateResponse;
    }

    public String getTranslateResult() {
        return TranslateResult;
    }

    public void setTranslateResult(String TranslateResult) {
        this.TranslateResult = TranslateResult;
    }

    public String getString() {
        return string;
    }

    public void setString(String string) {
        this.string = string;
    }

}
-- END SOAPResponse.java --

Re: My java client always returns (null)

Posted by Eric Carlson <er...@group-technical.com>.
Thanks Scott and for everyone elses help!
I'm, not there yet - but - you wouldn't believe this - there is an
example in the Axis download for this exact service ;-)
Ah well, off for a play again..

On Sun, 7 Mar 2004 09:16:55 -0500, you wrote:

>The problem you are experiencing is almost certainly because the service is document/literal.  Apache SOAP 2.3.1 only really supports rpc/encoded.  One of the "features" of .NET doc/lit is that it *demands* that xsi:type information *not* be sent for parameters.  When Apache SOAP sends this, .NET does not return a SOAP Fault, but instead returns and empty response.
>
>You have a couple of options if you want to access this service.  One is to move to Apache Axis, which fully supports doc/lit.  A second option is to use a nightly build of Apache SOAP, which adds the ability to specify doc/lit serialization on the client.  This is not "true" doc/lit, guided by WSDL, but instead "works well enough" support to address most users needs most of the time.
>
>Scott Nichol
>
>Do not send e-mail directly to this e-mail address,
>because it is filtered to accept only mail from
>specific mail lists.
>----- Original Message ----- 
>From: "Eric Carlson" <er...@group-technical.com>
>To: <so...@ws.apache.org>
>Sent: Saturday, March 06, 2004 9:32 AM
>Subject: My java client always returns (null)
>
>
>Hi,
>
>Sorry for the long post ;-)
>I have (honestly!) been trying hard to get as simple a java client
>going for a sexy looking webservice I've seen at xmethods but with no
>joy. It seems to connect but always returns null. If its ok, I'd like
>to show the wsdl and my java sources please? So if anyone has a moment
>can they give me a clue why I get null please?
>
>(My SOAPResponse is an attempt at a generic bean to handle responses.
>I think the real problem here is my lack of ability to see exactly
>which fields in the WSDL should be used for the mapping in my source,
>and how ;-)). Thanks very much in advance...)
>
>-- BEGIN WSDL --
><?xml version="1.0" encoding="utf-8"?>
><definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
>xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>xmlns:s="http://www.w3.org/2001/XMLSchema"
>xmlns:s0="http://www.webservicex.net/"
>xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
>xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
>xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
>targetNamespace="http://www.webservicex.net/"
>xmlns="http://schemas.xmlsoap.org/wsdl/">
>  <types>
>    <s:schema elementFormDefault="qualified"
>targetNamespace="http://www.webservicex.net/">
>      <s:element name="Translate">
>        <s:complexType>
>          <s:sequence>
>            <s:element minOccurs="1" maxOccurs="1" name="LanguageMode"
>type="s0:Language" />
>            <s:element minOccurs="0" maxOccurs="1" name="Text"
>type="s:string" />
>          </s:sequence>
>        </s:complexType>
>      </s:element>
>      <s:simpleType name="Language">
>        <s:restriction base="s:string">
>          <s:enumeration value="EnglishTOChinese" />
>          <s:enumeration value="EnglishTOFrench" />
>          <s:enumeration value="EnglishTOGerman" />
>          <s:enumeration value="EnglishTOItalian" />
>          <s:enumeration value="EnglishTOJapanese" />
>          <s:enumeration value="EnglishTOKorean" />
>          <s:enumeration value="EnglishTOPortuguese" />
>          <s:enumeration value="EnglishTOSpanish" />
>          <s:enumeration value="ChineseTOEnglish" />
>          <s:enumeration value="FrenchTOEnglish" />
>          <s:enumeration value="FrenchTOGerman" />
>          <s:enumeration value="GermanTOEnglish" />
>          <s:enumeration value="GermanTOFrench" />
>          <s:enumeration value="ItalianTOEnglish" />
>          <s:enumeration value="JapaneseTOEnglish" />
>          <s:enumeration value="KoreanTOEnglish" />
>          <s:enumeration value="PortugueseTOEnglish" />
>          <s:enumeration value="RussianTOEnglish" />
>          <s:enumeration value="SpanishTOEnglish" />
>        </s:restriction>
>      </s:simpleType>
>      <s:element name="TranslateResponse">
>        <s:complexType>
>          <s:sequence>
>            <s:element minOccurs="0" maxOccurs="1"
>name="TranslateResult" type="s:string" />
>          </s:sequence>
>        </s:complexType>
>      </s:element>
>      <s:element name="string" nillable="true" type="s:string" />
>    </s:schema>
>  </types>
>  <message name="TranslateSoapIn">
>    <part name="parameters" element="s0:Translate" />
>  </message>
>  <message name="TranslateSoapOut">
>    <part name="parameters" element="s0:TranslateResponse" />
>  </message>
>  <message name="TranslateHttpGetIn">
>    <part name="LanguageMode" type="s:string" />
>    <part name="Text" type="s:string" />
>  </message>
>  <message name="TranslateHttpGetOut">
>    <part name="Body" element="s0:string" />
>  </message>
>  <message name="TranslateHttpPostIn">
>    <part name="LanguageMode" type="s:string" />
>    <part name="Text" type="s:string" />
>  </message>
>  <message name="TranslateHttpPostOut">
>    <part name="Body" element="s0:string" />
>  </message>
>  <portType name="TranslationServiceSoap">
>    <operation name="Translate">
>      <documentation>Convert text from one language to another
>language .Supported languages are English to Chinese, English to
>French, English to German, English to Italian, English to Japanese,
>English to Korean, English to Portuguese, English to Spanish, Chinese
>to English, French to English, French to German, German to English,
>German to French, Italian to English, Japanese to English, Korean to
>English, Portuguese to English, Russian to English, Spanish to
>English.</documentation>
>      <input message="s0:TranslateSoapIn" />
>      <output message="s0:TranslateSoapOut" />
>    </operation>
>  </portType>
>  <portType name="TranslationServiceHttpGet">
>    <operation name="Translate">
>      <documentation>Convert text from one language to another
>language .Supported languages are English to Chinese, English to
>French, English to German, English to Italian, English to Japanese,
>English to Korean, English to Portuguese, English to Spanish, Chinese
>to English, French to English, French to German, German to English,
>German to French, Italian to English, Japanese to English, Korean to
>English, Portuguese to English, Russian to English, Spanish to
>English.</documentation>
>      <input message="s0:TranslateHttpGetIn" />
>      <output message="s0:TranslateHttpGetOut" />
>    </operation>
>  </portType>
>  <portType name="TranslationServiceHttpPost">
>    <operation name="Translate">
>      <documentation>Convert text from one language to another
>language .Supported languages are English to Chinese, English to
>French, English to German, English to Italian, English to Japanese,
>English to Korean, English to Portuguese, English to Spanish, Chinese
>to English, French to English, French to German, German to English,
>German to French, Italian to English, Japanese to English, Korean to
>English, Portuguese to English, Russian to English, Spanish to
>English.</documentation>
>      <input message="s0:TranslateHttpPostIn" />
>      <output message="s0:TranslateHttpPostOut" />
>    </operation>
>  </portType>
>  <binding name="TranslationServiceSoap"
>type="s0:TranslationServiceSoap">
>    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
>style="document" />
>    <operation name="Translate">
>      <soap:operation
>soapAction="http://www.webservicex.net/Translate" style="document" />
>      <input>
>        <soap:body use="literal" />
>      </input>
>      <output>
>        <soap:body use="literal" />
>      </output>
>    </operation>
>  </binding>
>  <binding name="TranslationServiceHttpGet"
>type="s0:TranslationServiceHttpGet">
>    <http:binding verb="GET" />
>    <operation name="Translate">
>      <http:operation location="/Translate" />
>      <input>
>        <http:urlEncoded />
>      </input>
>      <output>
>        <mime:mimeXml part="Body" />
>      </output>
>    </operation>
>  </binding>
>  <binding name="TranslationServiceHttpPost"
>type="s0:TranslationServiceHttpPost">
>    <http:binding verb="POST" />
>    <operation name="Translate">
>      <http:operation location="/Translate" />
>      <input>
>        <mime:content type="application/x-www-form-urlencoded" />
>      </input>
>      <output>
>        <mime:mimeXml part="Body" />
>      </output>
>    </operation>
>  </binding>
>  <service name="TranslationService">
>    <port name="TranslationServiceSoap"
>binding="s0:TranslationServiceSoap">
>      <soap:address
>location="http://www.webservicex.net/TranslateService.asmx" />
>    </port>
>    <port name="TranslationServiceHttpGet"
>binding="s0:TranslationServiceHttpGet">
>      <http:address
>location="http://www.webservicex.net/TranslateService.asmx" />
>    </port>
>    <port name="TranslationServiceHttpPost"
>binding="s0:TranslationServiceHttpPost">
>      <http:address
>location="http://www.webservicex.net/TranslateService.asmx" />
>    </port>
>  </service>
></definitions>
>-- END WSDL--
>
>-- BEGIN Translate.java --
>import java.io.*;
>import java.util.*;
>import java.net.*;
>import org.w3c.dom.*;
>import org.xml.sax.*;
>import javax.xml.parsers.*;
>import org.apache.soap.util.xml.*;
>import org.apache.soap.*;
>import org.apache.soap.encoding.*;
>import org.apache.soap.encoding.soapenc.*;
>import org.apache.soap.rpc.*;
>import org.apache.soap.transport.http.SOAPHTTPConnection;
>
>public class Translate {
>    public static void main (String[] args) {
>        try {
>
>    URL url = new
>URL("http://www.webservicex.com/TranslateService.asmx");
>
>    SOAPHTTPConnection st = new SOAPHTTPConnection();
>
>    Call call = new Call();
>            call.setSOAPTransport(st);
>
>            call.setTargetObjectURI("urn:TranslationServiceSOAP");
>    call.setMethodName("Translate");
>
>    SOAPMappingRegistry smr = new SOAPMappingRegistry();
>    call.setSOAPMappingRegistry(smr);
>
>    BeanSerializer beanSer = new BeanSerializer();
>
>    smr.mapTypes(Constants.NS_URI_SOAP_ENC,
>              new QName( "http://www.webservicex.net/",
>"TranslateResult"),
>                  SOAPResponse.class, beanSer, beanSer);
>
>    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
>
>    Vector params = new Vector();
>            params.addElement (new Parameter("LanguageMode",
>String.class, "EnglishTOFrench", null));
>            params.addElement (new Parameter("Text", String.class,
>"Hello", null));
>    call.setParams(params);
>
>            Response resp = null;
>            try {
>                resp = call.invoke(url,
>"http://www.webservicex.net/Translate");
>System.out.println(resp);
>    } catch(Exception e) {
>                System.err.println(e.toString());
>            }
>
>            Object value = null;
>
>    if (!resp.generatedFault()) {
>                Parameter ret = resp.getReturnValue();
>                value = ret.getValue();
>            } else {
>                Fault fault = resp.getFault();
>                System.err.println("SOAP call raised fault code:"
>            +fault.getFaultCode()
>                    +" Text:"+ fault.getFaultString());
>            }
>
>            System.out.println("Return value is "+value);
>        } catch (Exception e) {
>            e.printStackTrace();
>        }
>    }
>}
>-- END Translate.java --
>
>-- BEGIN SOAPResponse.java --
>import java.io.*;
>
>public class SOAPResponse {
>    public String TranslateResponse;
>    public String TranslateResult;
>    public String string;
>
>    public String toString() {
>        return TranslateResponse;
>    }
>
>    public SOAPResponse() {}
>
>    public String getTranslateResponse() {
>        return TranslateResponse;
>    }
>
>    public void setTranslateResponse(String TranslateResponse) {
>        this.TranslateResponse = TranslateResponse;
>    }
>
>    public String getTranslateResult() {
>        return TranslateResult;
>    }
>
>    public void setTranslateResult(String TranslateResult) {
>        this.TranslateResult = TranslateResult;
>    }
>
>    public String getString() {
>        return string;
>    }
>
>    public void setString(String string) {
>        this.string = string;
>    }
>
>}
>-- END SOAPResponse.java --


Re: Extract Binary File(pdf) from SOAP Attachment

Posted by Daniel Zhang <zh...@clinicaltools.com>.
Thanks, Scott!

-Daniel

Scott Nichol wrote:

>With SOAP 2.3.1, one uses the SOAPContext class to access attachments, and the SOAPContext instance is obtained from SOAPHTTPConnection.  This means doing roughly
>
>SOAPHTTPConnection shc = new SOAPHTTPConnection()
>...
>Call call = new Call();
>call.setTransport(shc);
>...
>Response resp = call.invoke(...);
>SOAPContext ctx = shc.getResponseSOAPContext();
>
>You can then access the message parts from ctx.
>
>Scott Nichol
>
>Do not send e-mail directly to this e-mail address,
>because it is filtered to accept only mail from
>specific mail lists.
>
>  
>
>>    
>>


Re: Extract Binary File(pdf) from SOAP Attachment

Posted by Scott Nichol <sn...@scottnichol.com>.
With SOAP 2.3.1, one uses the SOAPContext class to access attachments, and the SOAPContext instance is obtained from SOAPHTTPConnection.  This means doing roughly

SOAPHTTPConnection shc = new SOAPHTTPConnection()
...
Call call = new Call();
call.setTransport(shc);
...
Response resp = call.invoke(...);
SOAPContext ctx = shc.getResponseSOAPContext();

You can then access the message parts from ctx.

Scott Nichol

Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message ----- 
From: "Daniel Zhang" <zh...@clinicaltools.com>
To: <so...@ws.apache.org>
Sent: Tuesday, March 09, 2004 10:49 AM
Subject: Re: Extract Binary File(pdf) from SOAP Attachment


I am using Apache SOAP 2.3.1.  Thanks.  - Daniel

Scott Nichol wrote:

>Since you mention javax.xml.soap.AttachmentPart, I wonder if you are using Axis, not Apache SOAP.  If so, please post to axis-user@ws.apache.org.  If you are using Apache SOAP, post that info here and someone will help.
>
>Scott Nichol
>
>Do not send e-mail directly to this e-mail address,
>because it is filtered to accept only mail from
>specific mail lists.
>----- Original Message ----- 
>From: "Daniel Zhang" <zh...@clinicaltools.com>
>To: <so...@ws.apache.org>
>Sent: Monday, March 08, 2004 4:21 PM
>Subject: Extract Binary File(pdf) from SOAP Attachment
>
>
>Our client sent us a SOAP file in which they packaged pdf files as 
>AttachmentPart. Basically if you open the file, it has the following 
>structure:
>
>----Boundary_value
>Content-Type:  application/pdf
>Content-Id: pdfnameA
>
>%PDF-1.4
>...pdf content...
>%%EOF
>
>----Boundary_value
>Content-Type:  application/pdf
>Content-Id: pdfnameB
>
>%PDF-1.4
>...pdf content...
>%%EOF
>
>Question: How can I extract pdf files from this SOAP attachment? First, 
>I need to populate this soap file into a SOAPMessage object, then I 
>tried to use javax.xml.soap.AttachmentPart class, I can use 
>getContentId() and getContentType() to retrieve the header, but either 
>java.lang.Object getContent() or getDataHandler() lack the methods to 
>let me write the pdf content as a string to a file. Any ideas?
>
>TIA,
>
>-Daniel
>
>
>  
>

Re: Extract Binary File(pdf) from SOAP Attachment

Posted by Daniel Zhang <zh...@clinicaltools.com>.
I am using Apache SOAP 2.3.1.  Thanks.  - Daniel

Scott Nichol wrote:

>Since you mention javax.xml.soap.AttachmentPart, I wonder if you are using Axis, not Apache SOAP.  If so, please post to axis-user@ws.apache.org.  If you are using Apache SOAP, post that info here and someone will help.
>
>Scott Nichol
>
>Do not send e-mail directly to this e-mail address,
>because it is filtered to accept only mail from
>specific mail lists.
>----- Original Message ----- 
>From: "Daniel Zhang" <zh...@clinicaltools.com>
>To: <so...@ws.apache.org>
>Sent: Monday, March 08, 2004 4:21 PM
>Subject: Extract Binary File(pdf) from SOAP Attachment
>
>
>Our client sent us a SOAP file in which they packaged pdf files as 
>AttachmentPart. Basically if you open the file, it has the following 
>structure:
>
>----Boundary_value
>Content-Type:  application/pdf
>Content-Id: pdfnameA
>
>%PDF-1.4
>...pdf content...
>%%EOF
>
>----Boundary_value
>Content-Type:  application/pdf
>Content-Id: pdfnameB
>
>%PDF-1.4
>...pdf content...
>%%EOF
>
>Question: How can I extract pdf files from this SOAP attachment? First, 
>I need to populate this soap file into a SOAPMessage object, then I 
>tried to use javax.xml.soap.AttachmentPart class, I can use 
>getContentId() and getContentType() to retrieve the header, but either 
>java.lang.Object getContent() or getDataHandler() lack the methods to 
>let me write the pdf content as a string to a file. Any ideas?
>
>TIA,
>
>-Daniel
>
>
>  
>


Re: Extract Binary File(pdf) from SOAP Attachment

Posted by Scott Nichol <sn...@scottnichol.com>.
Since you mention javax.xml.soap.AttachmentPart, I wonder if you are using Axis, not Apache SOAP.  If so, please post to axis-user@ws.apache.org.  If you are using Apache SOAP, post that info here and someone will help.

Scott Nichol

Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message ----- 
From: "Daniel Zhang" <zh...@clinicaltools.com>
To: <so...@ws.apache.org>
Sent: Monday, March 08, 2004 4:21 PM
Subject: Extract Binary File(pdf) from SOAP Attachment


Our client sent us a SOAP file in which they packaged pdf files as 
AttachmentPart. Basically if you open the file, it has the following 
structure:

----Boundary_value
Content-Type:  application/pdf
Content-Id: pdfnameA

%PDF-1.4
...pdf content...
%%EOF

----Boundary_value
Content-Type:  application/pdf
Content-Id: pdfnameB

%PDF-1.4
...pdf content...
%%EOF

Question: How can I extract pdf files from this SOAP attachment? First, 
I need to populate this soap file into a SOAPMessage object, then I 
tried to use javax.xml.soap.AttachmentPart class, I can use 
getContentId() and getContentType() to retrieve the header, but either 
java.lang.Object getContent() or getDataHandler() lack the methods to 
let me write the pdf content as a string to a file. Any ideas?

TIA,

-Daniel



Extract Binary File(pdf) from SOAP Attachment

Posted by Daniel Zhang <zh...@clinicaltools.com>.
Our client sent us a SOAP file in which they packaged pdf files as 
AttachmentPart. Basically if you open the file, it has the following 
structure:

----Boundary_value
Content-Type:  application/pdf
Content-Id: pdfnameA

%PDF-1.4
...pdf content...
%%EOF

----Boundary_value
Content-Type:  application/pdf
Content-Id: pdfnameB

%PDF-1.4
...pdf content...
%%EOF

Question: How can I extract pdf files from this SOAP attachment? First, 
I need to populate this soap file into a SOAPMessage object, then I 
tried to use javax.xml.soap.AttachmentPart class, I can use 
getContentId() and getContentType() to retrieve the header, but either 
java.lang.Object getContent() or getDataHandler() lack the methods to 
let me write the pdf content as a string to a file. Any ideas?

TIA,

-Daniel


Re: My java client always returns (null)

Posted by Eric Carlson <er...@group-technical.com>.
Fixed as you said - moved over to Axis, used the WSDL2Java tool and
wrapped the xxxStub it generated into a test invoker - all very
painless in the end! Thanks again guys...

On Sun, 7 Mar 2004 09:16:55 -0500, you wrote:

>The problem you are experiencing is almost certainly because the service is document/literal.  Apache SOAP 2.3.1 only really supports rpc/encoded.  One of the "features" of .NET doc/lit is that it *demands* that xsi:type information *not* be sent for parameters.  When Apache SOAP sends this, .NET does not return a SOAP Fault, but instead returns and empty response.
>
>You have a couple of options if you want to access this service.  One is to move to Apache Axis, which fully supports doc/lit.  A second option is to use a nightly build of Apache SOAP, which adds the ability to specify doc/lit serialization on the client.  This is not "true" doc/lit, guided by WSDL, but instead "works well enough" support to address most users needs most of the time.
>
>Scott Nichol
>
>Do not send e-mail directly to this e-mail address,
>because it is filtered to accept only mail from
>specific mail lists.
>----- Original Message ----- 
>From: "Eric Carlson" <er...@group-technical.com>
>To: <so...@ws.apache.org>
>Sent: Saturday, March 06, 2004 9:32 AM
>Subject: My java client always returns (null)
>
>
>Hi,
>
>Sorry for the long post ;-)
>I have (honestly!) been trying hard to get as simple a java client
>going for a sexy looking webservice I've seen at xmethods but with no
>joy. It seems to connect but always returns null. If its ok, I'd like
>to show the wsdl and my java sources please? So if anyone has a moment
>can they give me a clue why I get null please?
>
>(My SOAPResponse is an attempt at a generic bean to handle responses.
>I think the real problem here is my lack of ability to see exactly
>which fields in the WSDL should be used for the mapping in my source,
>and how ;-)). Thanks very much in advance...)
>
>-- BEGIN WSDL --
><?xml version="1.0" encoding="utf-8"?>
><definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
>xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>xmlns:s="http://www.w3.org/2001/XMLSchema"
>xmlns:s0="http://www.webservicex.net/"
>xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
>xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
>xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
>targetNamespace="http://www.webservicex.net/"
>xmlns="http://schemas.xmlsoap.org/wsdl/">
>  <types>
>    <s:schema elementFormDefault="qualified"
>targetNamespace="http://www.webservicex.net/">
>      <s:element name="Translate">
>        <s:complexType>
>          <s:sequence>
>            <s:element minOccurs="1" maxOccurs="1" name="LanguageMode"
>type="s0:Language" />
>            <s:element minOccurs="0" maxOccurs="1" name="Text"
>type="s:string" />
>          </s:sequence>
>        </s:complexType>
>      </s:element>
>      <s:simpleType name="Language">
>        <s:restriction base="s:string">
>          <s:enumeration value="EnglishTOChinese" />
>          <s:enumeration value="EnglishTOFrench" />
>          <s:enumeration value="EnglishTOGerman" />
>          <s:enumeration value="EnglishTOItalian" />
>          <s:enumeration value="EnglishTOJapanese" />
>          <s:enumeration value="EnglishTOKorean" />
>          <s:enumeration value="EnglishTOPortuguese" />
>          <s:enumeration value="EnglishTOSpanish" />
>          <s:enumeration value="ChineseTOEnglish" />
>          <s:enumeration value="FrenchTOEnglish" />
>          <s:enumeration value="FrenchTOGerman" />
>          <s:enumeration value="GermanTOEnglish" />
>          <s:enumeration value="GermanTOFrench" />
>          <s:enumeration value="ItalianTOEnglish" />
>          <s:enumeration value="JapaneseTOEnglish" />
>          <s:enumeration value="KoreanTOEnglish" />
>          <s:enumeration value="PortugueseTOEnglish" />
>          <s:enumeration value="RussianTOEnglish" />
>          <s:enumeration value="SpanishTOEnglish" />
>        </s:restriction>
>      </s:simpleType>
>      <s:element name="TranslateResponse">
>        <s:complexType>
>          <s:sequence>
>            <s:element minOccurs="0" maxOccurs="1"
>name="TranslateResult" type="s:string" />
>          </s:sequence>
>        </s:complexType>
>      </s:element>
>      <s:element name="string" nillable="true" type="s:string" />
>    </s:schema>
>  </types>
>  <message name="TranslateSoapIn">
>    <part name="parameters" element="s0:Translate" />
>  </message>
>  <message name="TranslateSoapOut">
>    <part name="parameters" element="s0:TranslateResponse" />
>  </message>
>  <message name="TranslateHttpGetIn">
>    <part name="LanguageMode" type="s:string" />
>    <part name="Text" type="s:string" />
>  </message>
>  <message name="TranslateHttpGetOut">
>    <part name="Body" element="s0:string" />
>  </message>
>  <message name="TranslateHttpPostIn">
>    <part name="LanguageMode" type="s:string" />
>    <part name="Text" type="s:string" />
>  </message>
>  <message name="TranslateHttpPostOut">
>    <part name="Body" element="s0:string" />
>  </message>
>  <portType name="TranslationServiceSoap">
>    <operation name="Translate">
>      <documentation>Convert text from one language to another
>language .Supported languages are English to Chinese, English to
>French, English to German, English to Italian, English to Japanese,
>English to Korean, English to Portuguese, English to Spanish, Chinese
>to English, French to English, French to German, German to English,
>German to French, Italian to English, Japanese to English, Korean to
>English, Portuguese to English, Russian to English, Spanish to
>English.</documentation>
>      <input message="s0:TranslateSoapIn" />
>      <output message="s0:TranslateSoapOut" />
>    </operation>
>  </portType>
>  <portType name="TranslationServiceHttpGet">
>    <operation name="Translate">
>      <documentation>Convert text from one language to another
>language .Supported languages are English to Chinese, English to
>French, English to German, English to Italian, English to Japanese,
>English to Korean, English to Portuguese, English to Spanish, Chinese
>to English, French to English, French to German, German to English,
>German to French, Italian to English, Japanese to English, Korean to
>English, Portuguese to English, Russian to English, Spanish to
>English.</documentation>
>      <input message="s0:TranslateHttpGetIn" />
>      <output message="s0:TranslateHttpGetOut" />
>    </operation>
>  </portType>
>  <portType name="TranslationServiceHttpPost">
>    <operation name="Translate">
>      <documentation>Convert text from one language to another
>language .Supported languages are English to Chinese, English to
>French, English to German, English to Italian, English to Japanese,
>English to Korean, English to Portuguese, English to Spanish, Chinese
>to English, French to English, French to German, German to English,
>German to French, Italian to English, Japanese to English, Korean to
>English, Portuguese to English, Russian to English, Spanish to
>English.</documentation>
>      <input message="s0:TranslateHttpPostIn" />
>      <output message="s0:TranslateHttpPostOut" />
>    </operation>
>  </portType>
>  <binding name="TranslationServiceSoap"
>type="s0:TranslationServiceSoap">
>    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
>style="document" />
>    <operation name="Translate">
>      <soap:operation
>soapAction="http://www.webservicex.net/Translate" style="document" />
>      <input>
>        <soap:body use="literal" />
>      </input>
>      <output>
>        <soap:body use="literal" />
>      </output>
>    </operation>
>  </binding>
>  <binding name="TranslationServiceHttpGet"
>type="s0:TranslationServiceHttpGet">
>    <http:binding verb="GET" />
>    <operation name="Translate">
>      <http:operation location="/Translate" />
>      <input>
>        <http:urlEncoded />
>      </input>
>      <output>
>        <mime:mimeXml part="Body" />
>      </output>
>    </operation>
>  </binding>
>  <binding name="TranslationServiceHttpPost"
>type="s0:TranslationServiceHttpPost">
>    <http:binding verb="POST" />
>    <operation name="Translate">
>      <http:operation location="/Translate" />
>      <input>
>        <mime:content type="application/x-www-form-urlencoded" />
>      </input>
>      <output>
>        <mime:mimeXml part="Body" />
>      </output>
>    </operation>
>  </binding>
>  <service name="TranslationService">
>    <port name="TranslationServiceSoap"
>binding="s0:TranslationServiceSoap">
>      <soap:address
>location="http://www.webservicex.net/TranslateService.asmx" />
>    </port>
>    <port name="TranslationServiceHttpGet"
>binding="s0:TranslationServiceHttpGet">
>      <http:address
>location="http://www.webservicex.net/TranslateService.asmx" />
>    </port>
>    <port name="TranslationServiceHttpPost"
>binding="s0:TranslationServiceHttpPost">
>      <http:address
>location="http://www.webservicex.net/TranslateService.asmx" />
>    </port>
>  </service>
></definitions>
>-- END WSDL--
>
>-- BEGIN Translate.java --
>import java.io.*;
>import java.util.*;
>import java.net.*;
>import org.w3c.dom.*;
>import org.xml.sax.*;
>import javax.xml.parsers.*;
>import org.apache.soap.util.xml.*;
>import org.apache.soap.*;
>import org.apache.soap.encoding.*;
>import org.apache.soap.encoding.soapenc.*;
>import org.apache.soap.rpc.*;
>import org.apache.soap.transport.http.SOAPHTTPConnection;
>
>public class Translate {
>    public static void main (String[] args) {
>        try {
>
>    URL url = new
>URL("http://www.webservicex.com/TranslateService.asmx");
>
>    SOAPHTTPConnection st = new SOAPHTTPConnection();
>
>    Call call = new Call();
>            call.setSOAPTransport(st);
>
>            call.setTargetObjectURI("urn:TranslationServiceSOAP");
>    call.setMethodName("Translate");
>
>    SOAPMappingRegistry smr = new SOAPMappingRegistry();
>    call.setSOAPMappingRegistry(smr);
>
>    BeanSerializer beanSer = new BeanSerializer();
>
>    smr.mapTypes(Constants.NS_URI_SOAP_ENC,
>              new QName( "http://www.webservicex.net/",
>"TranslateResult"),
>                  SOAPResponse.class, beanSer, beanSer);
>
>    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
>
>    Vector params = new Vector();
>            params.addElement (new Parameter("LanguageMode",
>String.class, "EnglishTOFrench", null));
>            params.addElement (new Parameter("Text", String.class,
>"Hello", null));
>    call.setParams(params);
>
>            Response resp = null;
>            try {
>                resp = call.invoke(url,
>"http://www.webservicex.net/Translate");
>System.out.println(resp);
>    } catch(Exception e) {
>                System.err.println(e.toString());
>            }
>
>            Object value = null;
>
>    if (!resp.generatedFault()) {
>                Parameter ret = resp.getReturnValue();
>                value = ret.getValue();
>            } else {
>                Fault fault = resp.getFault();
>                System.err.println("SOAP call raised fault code:"
>            +fault.getFaultCode()
>                    +" Text:"+ fault.getFaultString());
>            }
>
>            System.out.println("Return value is "+value);
>        } catch (Exception e) {
>            e.printStackTrace();
>        }
>    }
>}
>-- END Translate.java --
>
>-- BEGIN SOAPResponse.java --
>import java.io.*;
>
>public class SOAPResponse {
>    public String TranslateResponse;
>    public String TranslateResult;
>    public String string;
>
>    public String toString() {
>        return TranslateResponse;
>    }
>
>    public SOAPResponse() {}
>
>    public String getTranslateResponse() {
>        return TranslateResponse;
>    }
>
>    public void setTranslateResponse(String TranslateResponse) {
>        this.TranslateResponse = TranslateResponse;
>    }
>
>    public String getTranslateResult() {
>        return TranslateResult;
>    }
>
>    public void setTranslateResult(String TranslateResult) {
>        this.TranslateResult = TranslateResult;
>    }
>
>    public String getString() {
>        return string;
>    }
>
>    public void setString(String string) {
>        this.string = string;
>    }
>
>}
>-- END SOAPResponse.java --


Re: My java client always returns (null)

Posted by Eric Carlson <er...@group-technical.com>.
Aaah wait ... no, I just realised thats the result of me doing a
WSDL2Java and thinking it hadn't done anything but in fact its put the
source in the Axis d/l dir. I'll get it soon ... honest!!!

On Sun, 7 Mar 2004 09:16:55 -0500, you wrote:

>The problem you are experiencing is almost certainly because the service is document/literal.  Apache SOAP 2.3.1 only really supports rpc/encoded.  One of the "features" of .NET doc/lit is that it *demands* that xsi:type information *not* be sent for parameters.  When Apache SOAP sends this, .NET does not return a SOAP Fault, but instead returns and empty response.
>
>You have a couple of options if you want to access this service.  One is to move to Apache Axis, which fully supports doc/lit.  A second option is to use a nightly build of Apache SOAP, which adds the ability to specify doc/lit serialization on the client.  This is not "true" doc/lit, guided by WSDL, but instead "works well enough" support to address most users needs most of the time.
>
>Scott Nichol
>
>Do not send e-mail directly to this e-mail address,
>because it is filtered to accept only mail from
>specific mail lists.
>----- Original Message ----- 
>From: "Eric Carlson" <er...@group-technical.com>
>To: <so...@ws.apache.org>
>Sent: Saturday, March 06, 2004 9:32 AM
>Subject: My java client always returns (null)
>
>
>Hi,
>
>Sorry for the long post ;-)
>I have (honestly!) been trying hard to get as simple a java client
>going for a sexy looking webservice I've seen at xmethods but with no
>joy. It seems to connect but always returns null. If its ok, I'd like
>to show the wsdl and my java sources please? So if anyone has a moment
>can they give me a clue why I get null please?
>
>(My SOAPResponse is an attempt at a generic bean to handle responses.
>I think the real problem here is my lack of ability to see exactly
>which fields in the WSDL should be used for the mapping in my source,
>and how ;-)). Thanks very much in advance...)
>
>-- BEGIN WSDL --
><?xml version="1.0" encoding="utf-8"?>
><definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
>xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>xmlns:s="http://www.w3.org/2001/XMLSchema"
>xmlns:s0="http://www.webservicex.net/"
>xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
>xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
>xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
>targetNamespace="http://www.webservicex.net/"
>xmlns="http://schemas.xmlsoap.org/wsdl/">
>  <types>
>    <s:schema elementFormDefault="qualified"
>targetNamespace="http://www.webservicex.net/">
>      <s:element name="Translate">
>        <s:complexType>
>          <s:sequence>
>            <s:element minOccurs="1" maxOccurs="1" name="LanguageMode"
>type="s0:Language" />
>            <s:element minOccurs="0" maxOccurs="1" name="Text"
>type="s:string" />
>          </s:sequence>
>        </s:complexType>
>      </s:element>
>      <s:simpleType name="Language">
>        <s:restriction base="s:string">
>          <s:enumeration value="EnglishTOChinese" />
>          <s:enumeration value="EnglishTOFrench" />
>          <s:enumeration value="EnglishTOGerman" />
>          <s:enumeration value="EnglishTOItalian" />
>          <s:enumeration value="EnglishTOJapanese" />
>          <s:enumeration value="EnglishTOKorean" />
>          <s:enumeration value="EnglishTOPortuguese" />
>          <s:enumeration value="EnglishTOSpanish" />
>          <s:enumeration value="ChineseTOEnglish" />
>          <s:enumeration value="FrenchTOEnglish" />
>          <s:enumeration value="FrenchTOGerman" />
>          <s:enumeration value="GermanTOEnglish" />
>          <s:enumeration value="GermanTOFrench" />
>          <s:enumeration value="ItalianTOEnglish" />
>          <s:enumeration value="JapaneseTOEnglish" />
>          <s:enumeration value="KoreanTOEnglish" />
>          <s:enumeration value="PortugueseTOEnglish" />
>          <s:enumeration value="RussianTOEnglish" />
>          <s:enumeration value="SpanishTOEnglish" />
>        </s:restriction>
>      </s:simpleType>
>      <s:element name="TranslateResponse">
>        <s:complexType>
>          <s:sequence>
>            <s:element minOccurs="0" maxOccurs="1"
>name="TranslateResult" type="s:string" />
>          </s:sequence>
>        </s:complexType>
>      </s:element>
>      <s:element name="string" nillable="true" type="s:string" />
>    </s:schema>
>  </types>
>  <message name="TranslateSoapIn">
>    <part name="parameters" element="s0:Translate" />
>  </message>
>  <message name="TranslateSoapOut">
>    <part name="parameters" element="s0:TranslateResponse" />
>  </message>
>  <message name="TranslateHttpGetIn">
>    <part name="LanguageMode" type="s:string" />
>    <part name="Text" type="s:string" />
>  </message>
>  <message name="TranslateHttpGetOut">
>    <part name="Body" element="s0:string" />
>  </message>
>  <message name="TranslateHttpPostIn">
>    <part name="LanguageMode" type="s:string" />
>    <part name="Text" type="s:string" />
>  </message>
>  <message name="TranslateHttpPostOut">
>    <part name="Body" element="s0:string" />
>  </message>
>  <portType name="TranslationServiceSoap">
>    <operation name="Translate">
>      <documentation>Convert text from one language to another
>language .Supported languages are English to Chinese, English to
>French, English to German, English to Italian, English to Japanese,
>English to Korean, English to Portuguese, English to Spanish, Chinese
>to English, French to English, French to German, German to English,
>German to French, Italian to English, Japanese to English, Korean to
>English, Portuguese to English, Russian to English, Spanish to
>English.</documentation>
>      <input message="s0:TranslateSoapIn" />
>      <output message="s0:TranslateSoapOut" />
>    </operation>
>  </portType>
>  <portType name="TranslationServiceHttpGet">
>    <operation name="Translate">
>      <documentation>Convert text from one language to another
>language .Supported languages are English to Chinese, English to
>French, English to German, English to Italian, English to Japanese,
>English to Korean, English to Portuguese, English to Spanish, Chinese
>to English, French to English, French to German, German to English,
>German to French, Italian to English, Japanese to English, Korean to
>English, Portuguese to English, Russian to English, Spanish to
>English.</documentation>
>      <input message="s0:TranslateHttpGetIn" />
>      <output message="s0:TranslateHttpGetOut" />
>    </operation>
>  </portType>
>  <portType name="TranslationServiceHttpPost">
>    <operation name="Translate">
>      <documentation>Convert text from one language to another
>language .Supported languages are English to Chinese, English to
>French, English to German, English to Italian, English to Japanese,
>English to Korean, English to Portuguese, English to Spanish, Chinese
>to English, French to English, French to German, German to English,
>German to French, Italian to English, Japanese to English, Korean to
>English, Portuguese to English, Russian to English, Spanish to
>English.</documentation>
>      <input message="s0:TranslateHttpPostIn" />
>      <output message="s0:TranslateHttpPostOut" />
>    </operation>
>  </portType>
>  <binding name="TranslationServiceSoap"
>type="s0:TranslationServiceSoap">
>    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
>style="document" />
>    <operation name="Translate">
>      <soap:operation
>soapAction="http://www.webservicex.net/Translate" style="document" />
>      <input>
>        <soap:body use="literal" />
>      </input>
>      <output>
>        <soap:body use="literal" />
>      </output>
>    </operation>
>  </binding>
>  <binding name="TranslationServiceHttpGet"
>type="s0:TranslationServiceHttpGet">
>    <http:binding verb="GET" />
>    <operation name="Translate">
>      <http:operation location="/Translate" />
>      <input>
>        <http:urlEncoded />
>      </input>
>      <output>
>        <mime:mimeXml part="Body" />
>      </output>
>    </operation>
>  </binding>
>  <binding name="TranslationServiceHttpPost"
>type="s0:TranslationServiceHttpPost">
>    <http:binding verb="POST" />
>    <operation name="Translate">
>      <http:operation location="/Translate" />
>      <input>
>        <mime:content type="application/x-www-form-urlencoded" />
>      </input>
>      <output>
>        <mime:mimeXml part="Body" />
>      </output>
>    </operation>
>  </binding>
>  <service name="TranslationService">
>    <port name="TranslationServiceSoap"
>binding="s0:TranslationServiceSoap">
>      <soap:address
>location="http://www.webservicex.net/TranslateService.asmx" />
>    </port>
>    <port name="TranslationServiceHttpGet"
>binding="s0:TranslationServiceHttpGet">
>      <http:address
>location="http://www.webservicex.net/TranslateService.asmx" />
>    </port>
>    <port name="TranslationServiceHttpPost"
>binding="s0:TranslationServiceHttpPost">
>      <http:address
>location="http://www.webservicex.net/TranslateService.asmx" />
>    </port>
>  </service>
></definitions>
>-- END WSDL--
>
>-- BEGIN Translate.java --
>import java.io.*;
>import java.util.*;
>import java.net.*;
>import org.w3c.dom.*;
>import org.xml.sax.*;
>import javax.xml.parsers.*;
>import org.apache.soap.util.xml.*;
>import org.apache.soap.*;
>import org.apache.soap.encoding.*;
>import org.apache.soap.encoding.soapenc.*;
>import org.apache.soap.rpc.*;
>import org.apache.soap.transport.http.SOAPHTTPConnection;
>
>public class Translate {
>    public static void main (String[] args) {
>        try {
>
>    URL url = new
>URL("http://www.webservicex.com/TranslateService.asmx");
>
>    SOAPHTTPConnection st = new SOAPHTTPConnection();
>
>    Call call = new Call();
>            call.setSOAPTransport(st);
>
>            call.setTargetObjectURI("urn:TranslationServiceSOAP");
>    call.setMethodName("Translate");
>
>    SOAPMappingRegistry smr = new SOAPMappingRegistry();
>    call.setSOAPMappingRegistry(smr);
>
>    BeanSerializer beanSer = new BeanSerializer();
>
>    smr.mapTypes(Constants.NS_URI_SOAP_ENC,
>              new QName( "http://www.webservicex.net/",
>"TranslateResult"),
>                  SOAPResponse.class, beanSer, beanSer);
>
>    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
>
>    Vector params = new Vector();
>            params.addElement (new Parameter("LanguageMode",
>String.class, "EnglishTOFrench", null));
>            params.addElement (new Parameter("Text", String.class,
>"Hello", null));
>    call.setParams(params);
>
>            Response resp = null;
>            try {
>                resp = call.invoke(url,
>"http://www.webservicex.net/Translate");
>System.out.println(resp);
>    } catch(Exception e) {
>                System.err.println(e.toString());
>            }
>
>            Object value = null;
>
>    if (!resp.generatedFault()) {
>                Parameter ret = resp.getReturnValue();
>                value = ret.getValue();
>            } else {
>                Fault fault = resp.getFault();
>                System.err.println("SOAP call raised fault code:"
>            +fault.getFaultCode()
>                    +" Text:"+ fault.getFaultString());
>            }
>
>            System.out.println("Return value is "+value);
>        } catch (Exception e) {
>            e.printStackTrace();
>        }
>    }
>}
>-- END Translate.java --
>
>-- BEGIN SOAPResponse.java --
>import java.io.*;
>
>public class SOAPResponse {
>    public String TranslateResponse;
>    public String TranslateResult;
>    public String string;
>
>    public String toString() {
>        return TranslateResponse;
>    }
>
>    public SOAPResponse() {}
>
>    public String getTranslateResponse() {
>        return TranslateResponse;
>    }
>
>    public void setTranslateResponse(String TranslateResponse) {
>        this.TranslateResponse = TranslateResponse;
>    }
>
>    public String getTranslateResult() {
>        return TranslateResult;
>    }
>
>    public void setTranslateResult(String TranslateResult) {
>        this.TranslateResult = TranslateResult;
>    }
>
>    public String getString() {
>        return string;
>    }
>
>    public void setString(String string) {
>        this.string = string;
>    }
>
>}
>-- END SOAPResponse.java --


Re: My java client always returns (null)

Posted by Scott Nichol <sn...@scottnichol.com>.
The problem you are experiencing is almost certainly because the service is document/literal.  Apache SOAP 2.3.1 only really supports rpc/encoded.  One of the "features" of .NET doc/lit is that it *demands* that xsi:type information *not* be sent for parameters.  When Apache SOAP sends this, .NET does not return a SOAP Fault, but instead returns and empty response.

You have a couple of options if you want to access this service.  One is to move to Apache Axis, which fully supports doc/lit.  A second option is to use a nightly build of Apache SOAP, which adds the ability to specify doc/lit serialization on the client.  This is not "true" doc/lit, guided by WSDL, but instead "works well enough" support to address most users needs most of the time.

Scott Nichol

Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message ----- 
From: "Eric Carlson" <er...@group-technical.com>
To: <so...@ws.apache.org>
Sent: Saturday, March 06, 2004 9:32 AM
Subject: My java client always returns (null)


Hi,

Sorry for the long post ;-)
I have (honestly!) been trying hard to get as simple a java client
going for a sexy looking webservice I've seen at xmethods but with no
joy. It seems to connect but always returns null. If its ok, I'd like
to show the wsdl and my java sources please? So if anyone has a moment
can they give me a clue why I get null please?

(My SOAPResponse is an attempt at a generic bean to handle responses.
I think the real problem here is my lack of ability to see exactly
which fields in the WSDL should be used for the mapping in my source,
and how ;-)). Thanks very much in advance...)

-- BEGIN WSDL --
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:s0="http://www.webservicex.net/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://www.webservicex.net/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types>
    <s:schema elementFormDefault="qualified"
targetNamespace="http://www.webservicex.net/">
      <s:element name="Translate">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="1" name="LanguageMode"
type="s0:Language" />
            <s:element minOccurs="0" maxOccurs="1" name="Text"
type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:simpleType name="Language">
        <s:restriction base="s:string">
          <s:enumeration value="EnglishTOChinese" />
          <s:enumeration value="EnglishTOFrench" />
          <s:enumeration value="EnglishTOGerman" />
          <s:enumeration value="EnglishTOItalian" />
          <s:enumeration value="EnglishTOJapanese" />
          <s:enumeration value="EnglishTOKorean" />
          <s:enumeration value="EnglishTOPortuguese" />
          <s:enumeration value="EnglishTOSpanish" />
          <s:enumeration value="ChineseTOEnglish" />
          <s:enumeration value="FrenchTOEnglish" />
          <s:enumeration value="FrenchTOGerman" />
          <s:enumeration value="GermanTOEnglish" />
          <s:enumeration value="GermanTOFrench" />
          <s:enumeration value="ItalianTOEnglish" />
          <s:enumeration value="JapaneseTOEnglish" />
          <s:enumeration value="KoreanTOEnglish" />
          <s:enumeration value="PortugueseTOEnglish" />
          <s:enumeration value="RussianTOEnglish" />
          <s:enumeration value="SpanishTOEnglish" />
        </s:restriction>
      </s:simpleType>
      <s:element name="TranslateResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1"
name="TranslateResult" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="string" nillable="true" type="s:string" />
    </s:schema>
  </types>
  <message name="TranslateSoapIn">
    <part name="parameters" element="s0:Translate" />
  </message>
  <message name="TranslateSoapOut">
    <part name="parameters" element="s0:TranslateResponse" />
  </message>
  <message name="TranslateHttpGetIn">
    <part name="LanguageMode" type="s:string" />
    <part name="Text" type="s:string" />
  </message>
  <message name="TranslateHttpGetOut">
    <part name="Body" element="s0:string" />
  </message>
  <message name="TranslateHttpPostIn">
    <part name="LanguageMode" type="s:string" />
    <part name="Text" type="s:string" />
  </message>
  <message name="TranslateHttpPostOut">
    <part name="Body" element="s0:string" />
  </message>
  <portType name="TranslationServiceSoap">
    <operation name="Translate">
      <documentation>Convert text from one language to another
language .Supported languages are English to Chinese, English to
French, English to German, English to Italian, English to Japanese,
English to Korean, English to Portuguese, English to Spanish, Chinese
to English, French to English, French to German, German to English,
German to French, Italian to English, Japanese to English, Korean to
English, Portuguese to English, Russian to English, Spanish to
English.</documentation>
      <input message="s0:TranslateSoapIn" />
      <output message="s0:TranslateSoapOut" />
    </operation>
  </portType>
  <portType name="TranslationServiceHttpGet">
    <operation name="Translate">
      <documentation>Convert text from one language to another
language .Supported languages are English to Chinese, English to
French, English to German, English to Italian, English to Japanese,
English to Korean, English to Portuguese, English to Spanish, Chinese
to English, French to English, French to German, German to English,
German to French, Italian to English, Japanese to English, Korean to
English, Portuguese to English, Russian to English, Spanish to
English.</documentation>
      <input message="s0:TranslateHttpGetIn" />
      <output message="s0:TranslateHttpGetOut" />
    </operation>
  </portType>
  <portType name="TranslationServiceHttpPost">
    <operation name="Translate">
      <documentation>Convert text from one language to another
language .Supported languages are English to Chinese, English to
French, English to German, English to Italian, English to Japanese,
English to Korean, English to Portuguese, English to Spanish, Chinese
to English, French to English, French to German, German to English,
German to French, Italian to English, Japanese to English, Korean to
English, Portuguese to English, Russian to English, Spanish to
English.</documentation>
      <input message="s0:TranslateHttpPostIn" />
      <output message="s0:TranslateHttpPostOut" />
    </operation>
  </portType>
  <binding name="TranslationServiceSoap"
type="s0:TranslationServiceSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
    <operation name="Translate">
      <soap:operation
soapAction="http://www.webservicex.net/Translate" style="document" />
      <input>
        <soap:body use="literal" />
      </input>
      <output>
        <soap:body use="literal" />
      </output>
    </operation>
  </binding>
  <binding name="TranslationServiceHttpGet"
type="s0:TranslationServiceHttpGet">
    <http:binding verb="GET" />
    <operation name="Translate">
      <http:operation location="/Translate" />
      <input>
        <http:urlEncoded />
      </input>
      <output>
        <mime:mimeXml part="Body" />
      </output>
    </operation>
  </binding>
  <binding name="TranslationServiceHttpPost"
type="s0:TranslationServiceHttpPost">
    <http:binding verb="POST" />
    <operation name="Translate">
      <http:operation location="/Translate" />
      <input>
        <mime:content type="application/x-www-form-urlencoded" />
      </input>
      <output>
        <mime:mimeXml part="Body" />
      </output>
    </operation>
  </binding>
  <service name="TranslationService">
    <port name="TranslationServiceSoap"
binding="s0:TranslationServiceSoap">
      <soap:address
location="http://www.webservicex.net/TranslateService.asmx" />
    </port>
    <port name="TranslationServiceHttpGet"
binding="s0:TranslationServiceHttpGet">
      <http:address
location="http://www.webservicex.net/TranslateService.asmx" />
    </port>
    <port name="TranslationServiceHttpPost"
binding="s0:TranslationServiceHttpPost">
      <http:address
location="http://www.webservicex.net/TranslateService.asmx" />
    </port>
  </service>
</definitions>
-- END WSDL--

-- BEGIN Translate.java --
import java.io.*;
import java.util.*;
import java.net.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import javax.xml.parsers.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.encoding.*;
import org.apache.soap.encoding.soapenc.*;
import org.apache.soap.rpc.*;
import org.apache.soap.transport.http.SOAPHTTPConnection;

public class Translate {
    public static void main (String[] args) {
        try {

    URL url = new
URL("http://www.webservicex.com/TranslateService.asmx");

    SOAPHTTPConnection st = new SOAPHTTPConnection();

    Call call = new Call();
            call.setSOAPTransport(st);

            call.setTargetObjectURI("urn:TranslationServiceSOAP");
    call.setMethodName("Translate");

    SOAPMappingRegistry smr = new SOAPMappingRegistry();
    call.setSOAPMappingRegistry(smr);

    BeanSerializer beanSer = new BeanSerializer();

    smr.mapTypes(Constants.NS_URI_SOAP_ENC,
              new QName( "http://www.webservicex.net/",
"TranslateResult"),
                  SOAPResponse.class, beanSer, beanSer);

    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

    Vector params = new Vector();
            params.addElement (new Parameter("LanguageMode",
String.class, "EnglishTOFrench", null));
            params.addElement (new Parameter("Text", String.class,
"Hello", null));
    call.setParams(params);

            Response resp = null;
            try {
                resp = call.invoke(url,
"http://www.webservicex.net/Translate");
System.out.println(resp);
    } catch(Exception e) {
                System.err.println(e.toString());
            }

            Object value = null;

    if (!resp.generatedFault()) {
                Parameter ret = resp.getReturnValue();
                value = ret.getValue();
            } else {
                Fault fault = resp.getFault();
                System.err.println("SOAP call raised fault code:"
            +fault.getFaultCode()
                    +" Text:"+ fault.getFaultString());
            }

            System.out.println("Return value is "+value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
-- END Translate.java --

-- BEGIN SOAPResponse.java --
import java.io.*;

public class SOAPResponse {
    public String TranslateResponse;
    public String TranslateResult;
    public String string;

    public String toString() {
        return TranslateResponse;
    }

    public SOAPResponse() {}

    public String getTranslateResponse() {
        return TranslateResponse;
    }

    public void setTranslateResponse(String TranslateResponse) {
        this.TranslateResponse = TranslateResponse;
    }

    public String getTranslateResult() {
        return TranslateResult;
    }

    public void setTranslateResult(String TranslateResult) {
        this.TranslateResult = TranslateResult;
    }

    public String getString() {
        return string;
    }

    public void setString(String string) {
        this.string = string;
    }

}
-- END SOAPResponse.java --


Re: My java client always returns (null)

Posted by Eric Carlson <er...@group-technical.com>.
Hi,

>Why dont you code the SOAP Server yourself ?

Huh? This offers a ready made translation service... or do you mean
some kind of stub server-that-calls-their server I'm not aware of?

>What application / features do you desire?

Language translation!

>You will not that running their demo
>http://www.webservicex.net/TranslateService.asmx/Translate?LanguageMode=Germ
>an&Text=Hello
>causes
>      The page cannot be displayed
>      There is a problem with the page you are trying to reach and it cannot
>be displayed.

That would have explained it except I cut and pasted from their demo
screen this link and its actually

http://www.webservicex.net/TranslateService.asmx/Translate?LanguageMode=EnglishTOFrench&Text=Hello

which is ok for me (be careful of the "LanguageMode" param").

Thanks again...

On Sat, 6 Mar 2004 14:39:09 -0500, you wrote:

>Eric
>
>--------------------------------------------------------------------------
>
>      Please try the following:
>
>        a.. Open the www.webservicex.net home page, and then look for links
>to the information you want.
>        b.. Click the  Refresh button, or try again later.
>
>        c.. Click  Search to look for information on the Internet.
>        d.. You can also see a list of related sites.
>
>
>
>
>      HTTP 500 - Internal server error
>      Internet Explorer
>
>So my suggestion is that their site at least the Translate SOAP Server is
>not yet operational
>Why dont you code the SOAP Server yourself ?
>What application / features do you desire?
>A great way for you to learn SOAP is to code the SOAP Server and the Client
>Regards,
>Martin Gainty
>----- Original Message -----
>From: "Eric Carlson" <er...@group-technical.com>
>To: <so...@ws.apache.org>; <mg...@hotmail.com>
>Sent: Saturday, March 06, 2004 12:33 PM
>Subject: Re: My java client always returns (null)
>
>
>Hi again, and thanks very much for your help!
>
>I took another tack. Because I know I'm getting a response from the
>server, I tried to compare what I'm sending with what their website
>says the service expects. I ran a http port sniffer and its like this:
>
>What I'm sending:
>
>POST / HTTP/1.0
>Host: localhost:81
>Content-Type: text/xml; charset=utf-8
>Content-Length: 528
>SOAPAction: "http://www.webservicex.net/Translate"
>
><?xml version='1.0' encoding='UTF-8'?>
><SOAP-ENV:Envelope
>xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>xmlns:xsd="http://www.w3.org/2001/XMLSchema">
><SOAP-ENV:Body>
><ns1:Translate xmlns:ns1="http://www.webservicex.net/"
>SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
><LanguageMode xsi:type="xsd:string">EnglishTOFrench</LanguageMode>
><Text xsi:type="xsd:string">Hello</Text>
></ns1:Translate>
></SOAP-ENV:Body>
></SOAP-ENV:Envelope>
>
>What the service expects:
>
>POST /TranslateService.asmx HTTP/1.1
>Host: www.webservicex.net
>Content-Type: text/xml; charset=utf-8
>Content-Length: length
>SOAPAction: "http://www.webservicex.net/Translate"
>
><?xml version="1.0" encoding="utf-8"?>
><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>  <soap:Body>
>    <Translate xmlns="http://www.webservicex.net/">
>      <LanguageMode>EnglishTOChinese or EnglishTOFrench or
>EnglishTOGerman or EnglishTOItalian or EnglishTOJapanese or
>EnglishTOKorean or EnglishTOPortuguese or EnglishTOSpanish or
>ChineseTOEnglish or FrenchTOEnglish or FrenchTOGerman or
>GermanTOEnglish or GermanTOFrench or ItalianTOEnglish or
>JapaneseTOEnglish or KoreanTOEnglish or PortugueseTOEnglish or
>RussianTOEnglish or SpanishTOEnglish</LanguageMode>
>      <Text>string</Text>
>    </Translate>
>  </soap:Body>
></soap:Envelope>
>
>Does anything jump out here?


Re: My java client always returns (null)

Posted by Martin Gainty <mg...@hotmail.com>.
Eric
You will not that running their demo
http://www.webservicex.net/TranslateService.asmx/Translate?LanguageMode=Germ
an&Text=Hello
causes
      The page cannot be displayed
      There is a problem with the page you are trying to reach and it cannot
be displayed.

--------------------------------------------------------------------------

      Please try the following:

        a.. Open the www.webservicex.net home page, and then look for links
to the information you want.
        b.. Click the  Refresh button, or try again later.

        c.. Click  Search to look for information on the Internet.
        d.. You can also see a list of related sites.




      HTTP 500 - Internal server error
      Internet Explorer

So my suggestion is that their site at least the Translate SOAP Server is
not yet operational
Why dont you code the SOAP Server yourself ?
What application / features do you desire?
A great way for you to learn SOAP is to code the SOAP Server and the Client
Regards,
Martin Gainty
----- Original Message -----
From: "Eric Carlson" <er...@group-technical.com>
To: <so...@ws.apache.org>; <mg...@hotmail.com>
Sent: Saturday, March 06, 2004 12:33 PM
Subject: Re: My java client always returns (null)


Hi again, and thanks very much for your help!

I took another tack. Because I know I'm getting a response from the
server, I tried to compare what I'm sending with what their website
says the service expects. I ran a http port sniffer and its like this:

What I'm sending:

POST / HTTP/1.0
Host: localhost:81
Content-Type: text/xml; charset=utf-8
Content-Length: 528
SOAPAction: "http://www.webservicex.net/Translate"

<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:Translate xmlns:ns1="http://www.webservicex.net/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<LanguageMode xsi:type="xsd:string">EnglishTOFrench</LanguageMode>
<Text xsi:type="xsd:string">Hello</Text>
</ns1:Translate>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

What the service expects:

POST /TranslateService.asmx HTTP/1.1
Host: www.webservicex.net
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.webservicex.net/Translate"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Translate xmlns="http://www.webservicex.net/">
      <LanguageMode>EnglishTOChinese or EnglishTOFrench or
EnglishTOGerman or EnglishTOItalian or EnglishTOJapanese or
EnglishTOKorean or EnglishTOPortuguese or EnglishTOSpanish or
ChineseTOEnglish or FrenchTOEnglish or FrenchTOGerman or
GermanTOEnglish or GermanTOFrench or ItalianTOEnglish or
JapaneseTOEnglish or KoreanTOEnglish or PortugueseTOEnglish or
RussianTOEnglish or SpanishTOEnglish</LanguageMode>
      <Text>string</Text>
    </Translate>
  </soap:Body>
</soap:Envelope>

Does anything jump out here?



Re: My java client always returns (null)

Posted by Eric Carlson <er...@group-technical.com>.
Hi again, and thanks very much for your help!

I took another tack. Because I know I'm getting a response from the
server, I tried to compare what I'm sending with what their website
says the service expects. I ran a http port sniffer and its like this:

What I'm sending:

POST / HTTP/1.0
Host: localhost:81
Content-Type: text/xml; charset=utf-8
Content-Length: 528
SOAPAction: "http://www.webservicex.net/Translate"

<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:Translate xmlns:ns1="http://www.webservicex.net/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<LanguageMode xsi:type="xsd:string">EnglishTOFrench</LanguageMode>
<Text xsi:type="xsd:string">Hello</Text>
</ns1:Translate>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

What the service expects:

POST /TranslateService.asmx HTTP/1.1
Host: www.webservicex.net
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.webservicex.net/Translate"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Translate xmlns="http://www.webservicex.net/">
      <LanguageMode>EnglishTOChinese or EnglishTOFrench or
EnglishTOGerman or EnglishTOItalian or EnglishTOJapanese or
EnglishTOKorean or EnglishTOPortuguese or EnglishTOSpanish or
ChineseTOEnglish or FrenchTOEnglish or FrenchTOGerman or
GermanTOEnglish or GermanTOFrench or ItalianTOEnglish or
JapaneseTOEnglish or KoreanTOEnglish or PortugueseTOEnglish or
RussianTOEnglish or SpanishTOEnglish</LanguageMode>
      <Text>string</Text>
    </Translate>
  </soap:Body>
</soap:Envelope>

Does anything jump out here?



Re: My java client always returns (null)

Posted by Martin Gainty <mg...@hotmail.com>.
Eric:
You need code at the Server end to process the WSDL 
I would need to see that code
-Martin
----- Original Message ----- 
From: "Eric Carlson" <er...@group-technical.com>
To: <so...@ws.apache.org>
Sent: Saturday, March 06, 2004 9:47 AM
Subject: Re: My java client always returns (null)


Nothing about my newbie attempts at SOAP is a dumb question !!!

Do you mean where does it actually live?
If so its here:
http://www.webservicex.net/WS/WSDetails.aspx?CATID=12&WSID=63


On Sat, 6 Mar 2004 09:35:53 -0500, you wrote:

>I'll ask the dumb question
>Where is the code for TranslateService.asmx?
>-Martin
>----- Original Message ----- 
>From: "Eric Carlson" <er...@group-technical.com>
>To: <so...@ws.apache.org>
>Sent: Saturday, March 06, 2004 9:32 AM
>Subject: My java client always returns (null)
>
>
>Hi,
>
>Sorry for the long post ;-)
>I have (honestly!) been trying hard to get as simple a java client
>going for a sexy looking webservice I've seen at xmethods but with no
>joy. It seems to connect but always returns null. If its ok, I'd like
>to show the wsdl and my java sources please? So if anyone has a moment
>can they give me a clue why I get null please?
>
>(My SOAPResponse is an attempt at a generic bean to handle responses.
>I think the real problem here is my lack of ability to see exactly
>which fields in the WSDL should be used for the mapping in my source,
>and how ;-)). Thanks very much in advance...)
>
>-- BEGIN WSDL --
><?xml version="1.0" encoding="utf-8"?>
><definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
>xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>xmlns:s="http://www.w3.org/2001/XMLSchema"
>xmlns:s0="http://www.webservicex.net/"
>xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
>xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
>xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
>targetNamespace="http://www.webservicex.net/"
>xmlns="http://schemas.xmlsoap.org/wsdl/">
>  <types>
>    <s:schema elementFormDefault="qualified"
>targetNamespace="http://www.webservicex.net/">
>      <s:element name="Translate">
>        <s:complexType>
>          <s:sequence>
>            <s:element minOccurs="1" maxOccurs="1" name="LanguageMode"
>type="s0:Language" />
>            <s:element minOccurs="0" maxOccurs="1" name="Text"
>type="s:string" />
>          </s:sequence>
>        </s:complexType>
>      </s:element>
>      <s:simpleType name="Language">
>        <s:restriction base="s:string">
>          <s:enumeration value="EnglishTOChinese" />
>          <s:enumeration value="EnglishTOFrench" />
>          <s:enumeration value="EnglishTOGerman" />
>          <s:enumeration value="EnglishTOItalian" />
>          <s:enumeration value="EnglishTOJapanese" />
>          <s:enumeration value="EnglishTOKorean" />
>          <s:enumeration value="EnglishTOPortuguese" />
>          <s:enumeration value="EnglishTOSpanish" />
>          <s:enumeration value="ChineseTOEnglish" />
>          <s:enumeration value="FrenchTOEnglish" />
>          <s:enumeration value="FrenchTOGerman" />
>          <s:enumeration value="GermanTOEnglish" />
>          <s:enumeration value="GermanTOFrench" />
>          <s:enumeration value="ItalianTOEnglish" />
>          <s:enumeration value="JapaneseTOEnglish" />
>          <s:enumeration value="KoreanTOEnglish" />
>          <s:enumeration value="PortugueseTOEnglish" />
>          <s:enumeration value="RussianTOEnglish" />
>          <s:enumeration value="SpanishTOEnglish" />
>        </s:restriction>
>      </s:simpleType>
>      <s:element name="TranslateResponse">
>        <s:complexType>
>          <s:sequence>
>            <s:element minOccurs="0" maxOccurs="1"
>name="TranslateResult" type="s:string" />
>          </s:sequence>
>        </s:complexType>
>      </s:element>
>      <s:element name="string" nillable="true" type="s:string" />
>    </s:schema>
>  </types>
>  <message name="TranslateSoapIn">
>    <part name="parameters" element="s0:Translate" />
>  </message>
>  <message name="TranslateSoapOut">
>    <part name="parameters" element="s0:TranslateResponse" />
>  </message>
>  <message name="TranslateHttpGetIn">
>    <part name="LanguageMode" type="s:string" />
>    <part name="Text" type="s:string" />
>  </message>
>  <message name="TranslateHttpGetOut">
>    <part name="Body" element="s0:string" />
>  </message>
>  <message name="TranslateHttpPostIn">
>    <part name="LanguageMode" type="s:string" />
>    <part name="Text" type="s:string" />
>  </message>
>  <message name="TranslateHttpPostOut">
>    <part name="Body" element="s0:string" />
>  </message>
>  <portType name="TranslationServiceSoap">
>    <operation name="Translate">
>      <documentation>Convert text from one language to another
>language .Supported languages are English to Chinese, English to
>French, English to German, English to Italian, English to Japanese,
>English to Korean, English to Portuguese, English to Spanish, Chinese
>to English, French to English, French to German, German to English,
>German to French, Italian to English, Japanese to English, Korean to
>English, Portuguese to English, Russian to English, Spanish to
>English.</documentation>
>      <input message="s0:TranslateSoapIn" />
>      <output message="s0:TranslateSoapOut" />
>    </operation>
>  </portType>
>  <portType name="TranslationServiceHttpGet">
>    <operation name="Translate">
>      <documentation>Convert text from one language to another
>language .Supported languages are English to Chinese, English to
>French, English to German, English to Italian, English to Japanese,
>English to Korean, English to Portuguese, English to Spanish, Chinese
>to English, French to English, French to German, German to English,
>German to French, Italian to English, Japanese to English, Korean to
>English, Portuguese to English, Russian to English, Spanish to
>English.</documentation>
>      <input message="s0:TranslateHttpGetIn" />
>      <output message="s0:TranslateHttpGetOut" />
>    </operation>
>  </portType>
>  <portType name="TranslationServiceHttpPost">
>    <operation name="Translate">
>      <documentation>Convert text from one language to another
>language .Supported languages are English to Chinese, English to
>French, English to German, English to Italian, English to Japanese,
>English to Korean, English to Portuguese, English to Spanish, Chinese
>to English, French to English, French to German, German to English,
>German to French, Italian to English, Japanese to English, Korean to
>English, Portuguese to English, Russian to English, Spanish to
>English.</documentation>
>      <input message="s0:TranslateHttpPostIn" />
>      <output message="s0:TranslateHttpPostOut" />
>    </operation>
>  </portType>
>  <binding name="TranslationServiceSoap"
>type="s0:TranslationServiceSoap">
>    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
>style="document" />
>    <operation name="Translate">
>      <soap:operation
>soapAction="http://www.webservicex.net/Translate" style="document" />
>      <input>
>        <soap:body use="literal" />
>      </input>
>      <output>
>        <soap:body use="literal" />
>      </output>
>    </operation>
>  </binding>
>  <binding name="TranslationServiceHttpGet"
>type="s0:TranslationServiceHttpGet">
>    <http:binding verb="GET" />
>    <operation name="Translate">
>      <http:operation location="/Translate" />
>      <input>
>        <http:urlEncoded />
>      </input>
>      <output>
>        <mime:mimeXml part="Body" />
>      </output>
>    </operation>
>  </binding>
>  <binding name="TranslationServiceHttpPost"
>type="s0:TranslationServiceHttpPost">
>    <http:binding verb="POST" />
>    <operation name="Translate">
>      <http:operation location="/Translate" />
>      <input>
>        <mime:content type="application/x-www-form-urlencoded" />
>      </input>
>      <output>
>        <mime:mimeXml part="Body" />
>      </output>
>    </operation>
>  </binding>
>  <service name="TranslationService">
>    <port name="TranslationServiceSoap"
>binding="s0:TranslationServiceSoap">
>      <soap:address
>location="http://www.webservicex.net/TranslateService.asmx" />
>    </port>
>    <port name="TranslationServiceHttpGet"
>binding="s0:TranslationServiceHttpGet">
>      <http:address
>location="http://www.webservicex.net/TranslateService.asmx" />
>    </port>
>    <port name="TranslationServiceHttpPost"
>binding="s0:TranslationServiceHttpPost">
>      <http:address
>location="http://www.webservicex.net/TranslateService.asmx" />
>    </port>
>  </service>
></definitions>
>-- END WSDL--
>
>-- BEGIN Translate.java --
>import java.io.*;
>import java.util.*;
>import java.net.*;
>import org.w3c.dom.*;
>import org.xml.sax.*;
>import javax.xml.parsers.*;
>import org.apache.soap.util.xml.*;
>import org.apache.soap.*;
>import org.apache.soap.encoding.*;
>import org.apache.soap.encoding.soapenc.*;
>import org.apache.soap.rpc.*;
>import org.apache.soap.transport.http.SOAPHTTPConnection;
>
>public class Translate {
>    public static void main (String[] args) {
>        try {
>
>    URL url = new
>URL("http://www.webservicex.com/TranslateService.asmx");
>
>    SOAPHTTPConnection st = new SOAPHTTPConnection();
>
>    Call call = new Call();
>            call.setSOAPTransport(st);
>
>            call.setTargetObjectURI("urn:TranslationServiceSOAP");
>    call.setMethodName("Translate");
>
>    SOAPMappingRegistry smr = new SOAPMappingRegistry();
>    call.setSOAPMappingRegistry(smr);
>
>    BeanSerializer beanSer = new BeanSerializer();
>
>    smr.mapTypes(Constants.NS_URI_SOAP_ENC,
>              new QName( "http://www.webservicex.net/",
>"TranslateResult"),
>                  SOAPResponse.class, beanSer, beanSer);
>
>    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
>
>    Vector params = new Vector();
>            params.addElement (new Parameter("LanguageMode",
>String.class, "EnglishTOFrench", null));
>            params.addElement (new Parameter("Text", String.class,
>"Hello", null));
>    call.setParams(params);
>
>            Response resp = null;
>            try {
>                resp = call.invoke(url,
>"http://www.webservicex.net/Translate");
>System.out.println(resp);
>    } catch(Exception e) {
>                System.err.println(e.toString());
>            }
>
>            Object value = null;
>
>    if (!resp.generatedFault()) {
>                Parameter ret = resp.getReturnValue();
>                value = ret.getValue();
>            } else {
>                Fault fault = resp.getFault();
>                System.err.println("SOAP call raised fault code:"
>            +fault.getFaultCode()
>                    +" Text:"+ fault.getFaultString());
>            }
>
>            System.out.println("Return value is "+value);
>        } catch (Exception e) {
>            e.printStackTrace();
>        }
>    }
>}
>-- END Translate.java --
>
>-- BEGIN SOAPResponse.java --
>import java.io.*;
>
>public class SOAPResponse {
>    public String TranslateResponse;
>    public String TranslateResult;
>    public String string;
>
>    public String toString() {
>        return TranslateResponse;
>    }
>
>    public SOAPResponse() {}
>
>    public String getTranslateResponse() {
>        return TranslateResponse;
>    }
>
>    public void setTranslateResponse(String TranslateResponse) {
>        this.TranslateResponse = TranslateResponse;
>    }
>
>    public String getTranslateResult() {
>        return TranslateResult;
>    }
>
>    public void setTranslateResult(String TranslateResult) {
>        this.TranslateResult = TranslateResult;
>    }
>
>    public String getString() {
>        return string;
>    }
>
>    public void setString(String string) {
>        this.string = string;
>    }
>
>}
>-- END SOAPResponse.java --


Re: My java client always returns (null)

Posted by Eric Carlson <er...@group-technical.com>.
Nothing about my newbie attempts at SOAP is a dumb question !!!

Do you mean where does it actually live?
If so its here:
http://www.webservicex.net/WS/WSDetails.aspx?CATID=12&WSID=63


On Sat, 6 Mar 2004 09:35:53 -0500, you wrote:

>I'll ask the dumb question
>Where is the code for TranslateService.asmx?
>-Martin
>----- Original Message ----- 
>From: "Eric Carlson" <er...@group-technical.com>
>To: <so...@ws.apache.org>
>Sent: Saturday, March 06, 2004 9:32 AM
>Subject: My java client always returns (null)
>
>
>Hi,
>
>Sorry for the long post ;-)
>I have (honestly!) been trying hard to get as simple a java client
>going for a sexy looking webservice I've seen at xmethods but with no
>joy. It seems to connect but always returns null. If its ok, I'd like
>to show the wsdl and my java sources please? So if anyone has a moment
>can they give me a clue why I get null please?
>
>(My SOAPResponse is an attempt at a generic bean to handle responses.
>I think the real problem here is my lack of ability to see exactly
>which fields in the WSDL should be used for the mapping in my source,
>and how ;-)). Thanks very much in advance...)
>
>-- BEGIN WSDL --
><?xml version="1.0" encoding="utf-8"?>
><definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
>xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>xmlns:s="http://www.w3.org/2001/XMLSchema"
>xmlns:s0="http://www.webservicex.net/"
>xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
>xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
>xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
>targetNamespace="http://www.webservicex.net/"
>xmlns="http://schemas.xmlsoap.org/wsdl/">
>  <types>
>    <s:schema elementFormDefault="qualified"
>targetNamespace="http://www.webservicex.net/">
>      <s:element name="Translate">
>        <s:complexType>
>          <s:sequence>
>            <s:element minOccurs="1" maxOccurs="1" name="LanguageMode"
>type="s0:Language" />
>            <s:element minOccurs="0" maxOccurs="1" name="Text"
>type="s:string" />
>          </s:sequence>
>        </s:complexType>
>      </s:element>
>      <s:simpleType name="Language">
>        <s:restriction base="s:string">
>          <s:enumeration value="EnglishTOChinese" />
>          <s:enumeration value="EnglishTOFrench" />
>          <s:enumeration value="EnglishTOGerman" />
>          <s:enumeration value="EnglishTOItalian" />
>          <s:enumeration value="EnglishTOJapanese" />
>          <s:enumeration value="EnglishTOKorean" />
>          <s:enumeration value="EnglishTOPortuguese" />
>          <s:enumeration value="EnglishTOSpanish" />
>          <s:enumeration value="ChineseTOEnglish" />
>          <s:enumeration value="FrenchTOEnglish" />
>          <s:enumeration value="FrenchTOGerman" />
>          <s:enumeration value="GermanTOEnglish" />
>          <s:enumeration value="GermanTOFrench" />
>          <s:enumeration value="ItalianTOEnglish" />
>          <s:enumeration value="JapaneseTOEnglish" />
>          <s:enumeration value="KoreanTOEnglish" />
>          <s:enumeration value="PortugueseTOEnglish" />
>          <s:enumeration value="RussianTOEnglish" />
>          <s:enumeration value="SpanishTOEnglish" />
>        </s:restriction>
>      </s:simpleType>
>      <s:element name="TranslateResponse">
>        <s:complexType>
>          <s:sequence>
>            <s:element minOccurs="0" maxOccurs="1"
>name="TranslateResult" type="s:string" />
>          </s:sequence>
>        </s:complexType>
>      </s:element>
>      <s:element name="string" nillable="true" type="s:string" />
>    </s:schema>
>  </types>
>  <message name="TranslateSoapIn">
>    <part name="parameters" element="s0:Translate" />
>  </message>
>  <message name="TranslateSoapOut">
>    <part name="parameters" element="s0:TranslateResponse" />
>  </message>
>  <message name="TranslateHttpGetIn">
>    <part name="LanguageMode" type="s:string" />
>    <part name="Text" type="s:string" />
>  </message>
>  <message name="TranslateHttpGetOut">
>    <part name="Body" element="s0:string" />
>  </message>
>  <message name="TranslateHttpPostIn">
>    <part name="LanguageMode" type="s:string" />
>    <part name="Text" type="s:string" />
>  </message>
>  <message name="TranslateHttpPostOut">
>    <part name="Body" element="s0:string" />
>  </message>
>  <portType name="TranslationServiceSoap">
>    <operation name="Translate">
>      <documentation>Convert text from one language to another
>language .Supported languages are English to Chinese, English to
>French, English to German, English to Italian, English to Japanese,
>English to Korean, English to Portuguese, English to Spanish, Chinese
>to English, French to English, French to German, German to English,
>German to French, Italian to English, Japanese to English, Korean to
>English, Portuguese to English, Russian to English, Spanish to
>English.</documentation>
>      <input message="s0:TranslateSoapIn" />
>      <output message="s0:TranslateSoapOut" />
>    </operation>
>  </portType>
>  <portType name="TranslationServiceHttpGet">
>    <operation name="Translate">
>      <documentation>Convert text from one language to another
>language .Supported languages are English to Chinese, English to
>French, English to German, English to Italian, English to Japanese,
>English to Korean, English to Portuguese, English to Spanish, Chinese
>to English, French to English, French to German, German to English,
>German to French, Italian to English, Japanese to English, Korean to
>English, Portuguese to English, Russian to English, Spanish to
>English.</documentation>
>      <input message="s0:TranslateHttpGetIn" />
>      <output message="s0:TranslateHttpGetOut" />
>    </operation>
>  </portType>
>  <portType name="TranslationServiceHttpPost">
>    <operation name="Translate">
>      <documentation>Convert text from one language to another
>language .Supported languages are English to Chinese, English to
>French, English to German, English to Italian, English to Japanese,
>English to Korean, English to Portuguese, English to Spanish, Chinese
>to English, French to English, French to German, German to English,
>German to French, Italian to English, Japanese to English, Korean to
>English, Portuguese to English, Russian to English, Spanish to
>English.</documentation>
>      <input message="s0:TranslateHttpPostIn" />
>      <output message="s0:TranslateHttpPostOut" />
>    </operation>
>  </portType>
>  <binding name="TranslationServiceSoap"
>type="s0:TranslationServiceSoap">
>    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
>style="document" />
>    <operation name="Translate">
>      <soap:operation
>soapAction="http://www.webservicex.net/Translate" style="document" />
>      <input>
>        <soap:body use="literal" />
>      </input>
>      <output>
>        <soap:body use="literal" />
>      </output>
>    </operation>
>  </binding>
>  <binding name="TranslationServiceHttpGet"
>type="s0:TranslationServiceHttpGet">
>    <http:binding verb="GET" />
>    <operation name="Translate">
>      <http:operation location="/Translate" />
>      <input>
>        <http:urlEncoded />
>      </input>
>      <output>
>        <mime:mimeXml part="Body" />
>      </output>
>    </operation>
>  </binding>
>  <binding name="TranslationServiceHttpPost"
>type="s0:TranslationServiceHttpPost">
>    <http:binding verb="POST" />
>    <operation name="Translate">
>      <http:operation location="/Translate" />
>      <input>
>        <mime:content type="application/x-www-form-urlencoded" />
>      </input>
>      <output>
>        <mime:mimeXml part="Body" />
>      </output>
>    </operation>
>  </binding>
>  <service name="TranslationService">
>    <port name="TranslationServiceSoap"
>binding="s0:TranslationServiceSoap">
>      <soap:address
>location="http://www.webservicex.net/TranslateService.asmx" />
>    </port>
>    <port name="TranslationServiceHttpGet"
>binding="s0:TranslationServiceHttpGet">
>      <http:address
>location="http://www.webservicex.net/TranslateService.asmx" />
>    </port>
>    <port name="TranslationServiceHttpPost"
>binding="s0:TranslationServiceHttpPost">
>      <http:address
>location="http://www.webservicex.net/TranslateService.asmx" />
>    </port>
>  </service>
></definitions>
>-- END WSDL--
>
>-- BEGIN Translate.java --
>import java.io.*;
>import java.util.*;
>import java.net.*;
>import org.w3c.dom.*;
>import org.xml.sax.*;
>import javax.xml.parsers.*;
>import org.apache.soap.util.xml.*;
>import org.apache.soap.*;
>import org.apache.soap.encoding.*;
>import org.apache.soap.encoding.soapenc.*;
>import org.apache.soap.rpc.*;
>import org.apache.soap.transport.http.SOAPHTTPConnection;
>
>public class Translate {
>    public static void main (String[] args) {
>        try {
>
>    URL url = new
>URL("http://www.webservicex.com/TranslateService.asmx");
>
>    SOAPHTTPConnection st = new SOAPHTTPConnection();
>
>    Call call = new Call();
>            call.setSOAPTransport(st);
>
>            call.setTargetObjectURI("urn:TranslationServiceSOAP");
>    call.setMethodName("Translate");
>
>    SOAPMappingRegistry smr = new SOAPMappingRegistry();
>    call.setSOAPMappingRegistry(smr);
>
>    BeanSerializer beanSer = new BeanSerializer();
>
>    smr.mapTypes(Constants.NS_URI_SOAP_ENC,
>              new QName( "http://www.webservicex.net/",
>"TranslateResult"),
>                  SOAPResponse.class, beanSer, beanSer);
>
>    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
>
>    Vector params = new Vector();
>            params.addElement (new Parameter("LanguageMode",
>String.class, "EnglishTOFrench", null));
>            params.addElement (new Parameter("Text", String.class,
>"Hello", null));
>    call.setParams(params);
>
>            Response resp = null;
>            try {
>                resp = call.invoke(url,
>"http://www.webservicex.net/Translate");
>System.out.println(resp);
>    } catch(Exception e) {
>                System.err.println(e.toString());
>            }
>
>            Object value = null;
>
>    if (!resp.generatedFault()) {
>                Parameter ret = resp.getReturnValue();
>                value = ret.getValue();
>            } else {
>                Fault fault = resp.getFault();
>                System.err.println("SOAP call raised fault code:"
>            +fault.getFaultCode()
>                    +" Text:"+ fault.getFaultString());
>            }
>
>            System.out.println("Return value is "+value);
>        } catch (Exception e) {
>            e.printStackTrace();
>        }
>    }
>}
>-- END Translate.java --
>
>-- BEGIN SOAPResponse.java --
>import java.io.*;
>
>public class SOAPResponse {
>    public String TranslateResponse;
>    public String TranslateResult;
>    public String string;
>
>    public String toString() {
>        return TranslateResponse;
>    }
>
>    public SOAPResponse() {}
>
>    public String getTranslateResponse() {
>        return TranslateResponse;
>    }
>
>    public void setTranslateResponse(String TranslateResponse) {
>        this.TranslateResponse = TranslateResponse;
>    }
>
>    public String getTranslateResult() {
>        return TranslateResult;
>    }
>
>    public void setTranslateResult(String TranslateResult) {
>        this.TranslateResult = TranslateResult;
>    }
>
>    public String getString() {
>        return string;
>    }
>
>    public void setString(String string) {
>        this.string = string;
>    }
>
>}
>-- END SOAPResponse.java --


Re: My java client always returns (null)

Posted by Martin Gainty <mg...@hotmail.com>.
I'll ask the dumb question
Where is the code for TranslateService.asmx?
-Martin
----- Original Message ----- 
From: "Eric Carlson" <er...@group-technical.com>
To: <so...@ws.apache.org>
Sent: Saturday, March 06, 2004 9:32 AM
Subject: My java client always returns (null)


Hi,

Sorry for the long post ;-)
I have (honestly!) been trying hard to get as simple a java client
going for a sexy looking webservice I've seen at xmethods but with no
joy. It seems to connect but always returns null. If its ok, I'd like
to show the wsdl and my java sources please? So if anyone has a moment
can they give me a clue why I get null please?

(My SOAPResponse is an attempt at a generic bean to handle responses.
I think the real problem here is my lack of ability to see exactly
which fields in the WSDL should be used for the mapping in my source,
and how ;-)). Thanks very much in advance...)

-- BEGIN WSDL --
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:s0="http://www.webservicex.net/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://www.webservicex.net/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types>
    <s:schema elementFormDefault="qualified"
targetNamespace="http://www.webservicex.net/">
      <s:element name="Translate">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="1" name="LanguageMode"
type="s0:Language" />
            <s:element minOccurs="0" maxOccurs="1" name="Text"
type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:simpleType name="Language">
        <s:restriction base="s:string">
          <s:enumeration value="EnglishTOChinese" />
          <s:enumeration value="EnglishTOFrench" />
          <s:enumeration value="EnglishTOGerman" />
          <s:enumeration value="EnglishTOItalian" />
          <s:enumeration value="EnglishTOJapanese" />
          <s:enumeration value="EnglishTOKorean" />
          <s:enumeration value="EnglishTOPortuguese" />
          <s:enumeration value="EnglishTOSpanish" />
          <s:enumeration value="ChineseTOEnglish" />
          <s:enumeration value="FrenchTOEnglish" />
          <s:enumeration value="FrenchTOGerman" />
          <s:enumeration value="GermanTOEnglish" />
          <s:enumeration value="GermanTOFrench" />
          <s:enumeration value="ItalianTOEnglish" />
          <s:enumeration value="JapaneseTOEnglish" />
          <s:enumeration value="KoreanTOEnglish" />
          <s:enumeration value="PortugueseTOEnglish" />
          <s:enumeration value="RussianTOEnglish" />
          <s:enumeration value="SpanishTOEnglish" />
        </s:restriction>
      </s:simpleType>
      <s:element name="TranslateResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1"
name="TranslateResult" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="string" nillable="true" type="s:string" />
    </s:schema>
  </types>
  <message name="TranslateSoapIn">
    <part name="parameters" element="s0:Translate" />
  </message>
  <message name="TranslateSoapOut">
    <part name="parameters" element="s0:TranslateResponse" />
  </message>
  <message name="TranslateHttpGetIn">
    <part name="LanguageMode" type="s:string" />
    <part name="Text" type="s:string" />
  </message>
  <message name="TranslateHttpGetOut">
    <part name="Body" element="s0:string" />
  </message>
  <message name="TranslateHttpPostIn">
    <part name="LanguageMode" type="s:string" />
    <part name="Text" type="s:string" />
  </message>
  <message name="TranslateHttpPostOut">
    <part name="Body" element="s0:string" />
  </message>
  <portType name="TranslationServiceSoap">
    <operation name="Translate">
      <documentation>Convert text from one language to another
language .Supported languages are English to Chinese, English to
French, English to German, English to Italian, English to Japanese,
English to Korean, English to Portuguese, English to Spanish, Chinese
to English, French to English, French to German, German to English,
German to French, Italian to English, Japanese to English, Korean to
English, Portuguese to English, Russian to English, Spanish to
English.</documentation>
      <input message="s0:TranslateSoapIn" />
      <output message="s0:TranslateSoapOut" />
    </operation>
  </portType>
  <portType name="TranslationServiceHttpGet">
    <operation name="Translate">
      <documentation>Convert text from one language to another
language .Supported languages are English to Chinese, English to
French, English to German, English to Italian, English to Japanese,
English to Korean, English to Portuguese, English to Spanish, Chinese
to English, French to English, French to German, German to English,
German to French, Italian to English, Japanese to English, Korean to
English, Portuguese to English, Russian to English, Spanish to
English.</documentation>
      <input message="s0:TranslateHttpGetIn" />
      <output message="s0:TranslateHttpGetOut" />
    </operation>
  </portType>
  <portType name="TranslationServiceHttpPost">
    <operation name="Translate">
      <documentation>Convert text from one language to another
language .Supported languages are English to Chinese, English to
French, English to German, English to Italian, English to Japanese,
English to Korean, English to Portuguese, English to Spanish, Chinese
to English, French to English, French to German, German to English,
German to French, Italian to English, Japanese to English, Korean to
English, Portuguese to English, Russian to English, Spanish to
English.</documentation>
      <input message="s0:TranslateHttpPostIn" />
      <output message="s0:TranslateHttpPostOut" />
    </operation>
  </portType>
  <binding name="TranslationServiceSoap"
type="s0:TranslationServiceSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
    <operation name="Translate">
      <soap:operation
soapAction="http://www.webservicex.net/Translate" style="document" />
      <input>
        <soap:body use="literal" />
      </input>
      <output>
        <soap:body use="literal" />
      </output>
    </operation>
  </binding>
  <binding name="TranslationServiceHttpGet"
type="s0:TranslationServiceHttpGet">
    <http:binding verb="GET" />
    <operation name="Translate">
      <http:operation location="/Translate" />
      <input>
        <http:urlEncoded />
      </input>
      <output>
        <mime:mimeXml part="Body" />
      </output>
    </operation>
  </binding>
  <binding name="TranslationServiceHttpPost"
type="s0:TranslationServiceHttpPost">
    <http:binding verb="POST" />
    <operation name="Translate">
      <http:operation location="/Translate" />
      <input>
        <mime:content type="application/x-www-form-urlencoded" />
      </input>
      <output>
        <mime:mimeXml part="Body" />
      </output>
    </operation>
  </binding>
  <service name="TranslationService">
    <port name="TranslationServiceSoap"
binding="s0:TranslationServiceSoap">
      <soap:address
location="http://www.webservicex.net/TranslateService.asmx" />
    </port>
    <port name="TranslationServiceHttpGet"
binding="s0:TranslationServiceHttpGet">
      <http:address
location="http://www.webservicex.net/TranslateService.asmx" />
    </port>
    <port name="TranslationServiceHttpPost"
binding="s0:TranslationServiceHttpPost">
      <http:address
location="http://www.webservicex.net/TranslateService.asmx" />
    </port>
  </service>
</definitions>
-- END WSDL--

-- BEGIN Translate.java --
import java.io.*;
import java.util.*;
import java.net.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import javax.xml.parsers.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.encoding.*;
import org.apache.soap.encoding.soapenc.*;
import org.apache.soap.rpc.*;
import org.apache.soap.transport.http.SOAPHTTPConnection;

public class Translate {
    public static void main (String[] args) {
        try {

    URL url = new
URL("http://www.webservicex.com/TranslateService.asmx");

    SOAPHTTPConnection st = new SOAPHTTPConnection();

    Call call = new Call();
            call.setSOAPTransport(st);

            call.setTargetObjectURI("urn:TranslationServiceSOAP");
    call.setMethodName("Translate");

    SOAPMappingRegistry smr = new SOAPMappingRegistry();
    call.setSOAPMappingRegistry(smr);

    BeanSerializer beanSer = new BeanSerializer();

    smr.mapTypes(Constants.NS_URI_SOAP_ENC,
              new QName( "http://www.webservicex.net/",
"TranslateResult"),
                  SOAPResponse.class, beanSer, beanSer);

    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

    Vector params = new Vector();
            params.addElement (new Parameter("LanguageMode",
String.class, "EnglishTOFrench", null));
            params.addElement (new Parameter("Text", String.class,
"Hello", null));
    call.setParams(params);

            Response resp = null;
            try {
                resp = call.invoke(url,
"http://www.webservicex.net/Translate");
System.out.println(resp);
    } catch(Exception e) {
                System.err.println(e.toString());
            }

            Object value = null;

    if (!resp.generatedFault()) {
                Parameter ret = resp.getReturnValue();
                value = ret.getValue();
            } else {
                Fault fault = resp.getFault();
                System.err.println("SOAP call raised fault code:"
            +fault.getFaultCode()
                    +" Text:"+ fault.getFaultString());
            }

            System.out.println("Return value is "+value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
-- END Translate.java --

-- BEGIN SOAPResponse.java --
import java.io.*;

public class SOAPResponse {
    public String TranslateResponse;
    public String TranslateResult;
    public String string;

    public String toString() {
        return TranslateResponse;
    }

    public SOAPResponse() {}

    public String getTranslateResponse() {
        return TranslateResponse;
    }

    public void setTranslateResponse(String TranslateResponse) {
        this.TranslateResponse = TranslateResponse;
    }

    public String getTranslateResult() {
        return TranslateResult;
    }

    public void setTranslateResult(String TranslateResult) {
        this.TranslateResult = TranslateResult;
    }

    public String getString() {
        return string;
    }

    public void setString(String string) {
        this.string = string;
    }

}
-- END SOAPResponse.java --