Hi All,

I am using the JAX WS to create Dispatch object to invoke a remote service.
The below is my wsdl file and my client code. when i try to execute my
client i am getting socket time out error. Can any one tell me where im
doing wrong.

I am very new to web service. Kindly do help me in solving this.
Thanks in advance.

WSDL:NUSOAP format

<definitions targetNamespace="urn:V3Map">
        <types>
        <xsd:schema targetNamespace="urn:V3Map">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
</xsd:schema>
</types>
        <message name="mapSearch1Request">
<part name="mapSearchInput1" type="xsd:string"/>
</message>
        <message name="mapSearch1Response">
<part name="return" type="xsd:string"/>
</message>

<portType name="V3MapPortType">
        <operation name="mapSearch1">
<input message="tns:mapSearch1Request"/>
<output message="tns:mapSearch1Response"/>
</operation>
</portType>

<binding name="V3MapBinding" type="tns:V3MapPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>

<operation name="mapSearch1">
<soap:operation soapAction="urn:V3Map#mapSearch1" style="rpc"/>

<input>
<soap:body use="encoded" namespace="urn:V3Map"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>

<output>
<soap:body use="encoded" namespace="urn:V3Map"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>

<service name="V3Map">
<port name="V3MapPort" binding="tns:V3MapBinding">
<soap:address location="http://sample/V3MapService/V3MapService.php"/>
</port>
</service>
</definitions>

This is my client code :

package sg.sphsearch.sfe.cxf.map.client;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
import javax.xml.ws.soap.SOAPBinding;

public class HelloWorldClient {

    public static void main(String[] args) {
        try {      
            // Define the service.
            QName svcQname = new QName(
                    "urn:V3Map", 
                    "V3Map");
            QName portQName = new QName(
                    "urn:V3Map", 
                    "V3MapPort");
            Service svc = Service.create(svcQname);
            svc.addPort(
                    portQName, 
                    SOAPBinding.SOAP11HTTP_BINDING,
                    "http://sample/mapguide/V3MapService/V3MapService.php";);

            // Create the dynamic invocation object from this service.
            Dispatch<Source> dispatch = svc.createDispatch(
                    portQName, 
                    Source.class, 
                    Service.Mode.MESSAGE);

            // Build the message.
            String content = 
                    "<ns2:mapSearch1 xmlns:ns2=\"urn:V3Map\">" +
                     
"<mapSearchInput1><input><password>password</password><username>userid</username><keywords>368324</keywords></input></mapSearchInput1>"
+
                    "</ns2:mapSearch1>";
            ByteArrayInputStream bais = new
ByteArrayInputStream(content.getBytes());
            Source input = new StreamSource(bais);
            System.out.println(input);
            // Invoke the operation.
            Source output = dispatch.invoke(input);
            System.out.println(output);
            // Process the response.
            StreamResult result = new StreamResult(new
ByteArrayOutputStream());
            Transformer trans =
TransformerFactory.newInstance().newTransformer();
            trans.transform(output, result);
            ByteArrayOutputStream baos = (ByteArrayOutputStream)
result.getOutputStream();

            // Write out the response content.
            String responseContent = new String(baos.toByteArray());
            System.out.println(responseContent);
        }
        catch (Throwable t) {
            t.printStackTrace();
        }
    }
}

Can you please tell me where im going wrong.
This is my error message

Feb 22, 2008 9:22:46 AM org.apache.cxf.configuration.spring.ConfigurerImpl
<init>
INFO: Could not find the configuration file cxf.xml on the classpath.
Feb 22, 2008 9:22:46 AM
org.apache.cxf.service.factory.ReflectionServiceFactoryBean
buildServiceFromClass
INFO: Creating Service
{http://sample/mapguide/V3MapService/V3MapService.php}V3Map from class
org.apache.cxf.jaxws.support.DummyImpl
Feb 22, 2008 9:22:47 AM org.apache.cxf.configuration.spring.ConfigurerImpl
getBeanName
INFO: Could not determine bean name for instance of class
org.apache.cxf.jaxws.DispatchImpl.
Feb 22, 2008 9:22:47 AM org.apache.cxf.jaxws.DispatchImpl invoke
INFO: Dispatch: invoke called
[EMAIL PROTECTED]
Feb 22, 2008 9:23:48 AM org.apache.cxf.phase.PhaseInterceptorChain
doIntercept
INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
        at
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
        at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:207)
        at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:173)
        at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:122)
        at
sg.sphsearch.sfe.cxf.map.client.HelloWorldClient.main(HelloWorldClient.java:47)
Caused by: java.net.SocketTimeoutException: Read timed out
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(Unknown Source)
        at java.io.BufferedInputStream.fill(Unknown Source)
        at java.io.BufferedInputStream.read1(Unknown Source)
        at java.io.BufferedInputStream.read(Unknown Source)
        at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
        at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
        at java.net.HttpURLConnection.getResponseCode(Unknown Source)
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1863)
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1791)
        at 
org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
        at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:575)
        at
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
        ... 4 more
javax.xml.ws.soap.SOAPFaultException: Could not send Message.
        at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:184)
        at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:122)
        at
sg.sphsearch.sfe.cxf.map.client.HelloWorldClient.main(HelloWorldClient.java:47)



-- 
View this message in context: 
http://www.nabble.com/JAX-WS---Dispatch-object-issue-tp15625751p15625751.html
Sent from the cxf-dev mailing list archive at Nabble.com.

Reply via email to