users@jax-rpc.java.net

Client application for using a .NET service

From: Onur Sencer <Onur.Sencer_at_telenity.com>
Date: Tue, 21 Sep 2004 21:46:24 +0300

Hi all
I wrote a code for getting information from .NET service. The client code is below. After execution I get no exception but I also can't get the string that needs to return. I could not find the error, so I started thinking if we can't reach .NET applications with jax-rpc. Is the error related with the types of arguments?

regards
Onur

package src.client.hello;
                 
import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.rpc.JAXRPCException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.ParameterMode;
import java.math.*;

public class TranslateRPCForDotNet {

    private static String qnameService = "TranslationService";
    private static String qnamePort = "TranslationServiceSoap";

    private static String BODY_NAMESPACE_VALUE =
        "http://stanski.com/webservices/";
    private static String ENCODING_STYLE_PROPERTY =
         "javax.xml.rpc.encodingstyle.namespace.uri";
    private static String NS_XSD =
        "http://www.w3.org/2001/XMLSchema";
    private static String URI_ENCODING =
         "";
    //"http://schemas.xmlsoap.org/soap/encoding/";
         

    public static void main(String[] args) {

        String endpointaddress="http://www.stanski.com/services/translate/translate.asmx";
        System.out.println("Endpoint address = " + endpointaddress);

        try {
            ServiceFactory factory =
                ServiceFactory.newInstance();
            Service service =
                factory.createService(
                new QName(qnameService));
    
            QName port = new QName(qnamePort);
    
            Call call = service.createCall(port);
            
            call.setTargetEndpointAddress(endpointaddress);
    
            call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY,
                URI_ENCODING);

            call.setProperty(Call.SOAPACTION_USE_PROPERTY,
                new Boolean(true));
            call.setProperty(Call.SOAPACTION_URI_PROPERTY,
                 "http://stanski.com/webservices/Translate");
            
            QName QNAME_TYPE_STRING =
                        new QName(NS_XSD, "string");
            QName QNAME_TYPE_INTEGER =
                        new QName(NS_XSD, "integer");
            call.setReturnType(QNAME_TYPE_STRING);

            call.setOperationName(
                new QName(BODY_NAMESPACE_VALUE,"Translate"));
            call.addParameter("strLanguage", QNAME_TYPE_STRING,
                ParameterMode.IN);
            call.addParameter("strMessage", QNAME_TYPE_STRING,
                ParameterMode.IN);
            String[] params = { "en_fr","hello" };

            String result = (String) call.invoke(params);
            System.out.println("french"+result);

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net