Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Connect to WebService Exception, Axis2

843833Oct 23 2008 — edited Oct 23 2008
Hi.
I have web service that I would like to use. Here is it's wsdl:
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="IMapCenterServiceservice" targetNamespace="http://tempuri.org/" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns1="urn:MCSoapClasses" xmlns:ns2="http://www.borland.com/namespaces/Types" xmlns:ns3="urn:MapCenter2_API_Types">
	<types>
		<xs:schema targetNamespace="urn:MCSoapClasses">
			<xs:complexType name="TSoapCreateSessionID__mcsResult">
				<xs:sequence>
					<xs:element name="SoapResult" type="xs:int"/>
					<xs:element name="SessionID" type="xs:string"/>
				</xs:sequence>
			</xs:complexType>
		</xs:schema>
	</types>
	<message name="CreateSessionID0Request"/>
	<message name="CreateSessionID0Response">
		<part name="return" type="ns1:TSoapCreateSessionID__mcsResult"/>
	</message>
	<portType name="IMapCenterService">
		<operation name="CreateSessionID">
			<input message="tns:CreateSessionID0Request"/>
			<output message="tns:CreateSessionID0Response"/>
		</operation>
	</portType>
	<binding name="IMapCenterServicebinding" type="tns:IMapCenterService">
		<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
			<operation name="CreateSessionID">
				<soap:operation soapAction="urn:MCSoapIntf-IMapCenterService#CreateSessionID" style="rpc"/>
					<input>
						<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:MCSoapIntf-IMapCenterService"/>
					</input>
					<output>
						<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:MCSoapIntf-IMapCenterService"/>
					</output>
			</operation>
	</binding>
	<service name="IMapCenterServiceservice">
		<port name="IMapCenterServicePort" binding="tns:IMapCenterServicebinding">
			<soap:address location="http://10.0.5.208:6090/soap/IMapCenterService"/>
		</port>
	</service>
</definitions>
I'm trying to connect to this service and invoke operation CreateSessionID. I'm choose axis2 to connect to this web service and here is the source for my client written in Java:
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;

public class MapCenterTest {

	public static void main(String[] args) throws AxisFault {
		try {
			ServiceClient client = new ServiceClient();
			Options opts = new Options();
			opts.setTo(new EndpointReference("http://10.0.5.208:6090/soap/IMapCenterService"));
			opts.setAction("urn:MCSoapIntf-IMapCenterService#CreateSessionID");
			client.setOptions(opts);
			OMElement res = client.sendReceive(createPayLoad());
			System.err.println(res);
		} catch (Exception e) {
			e.printStackTrace();
			System.err.println("\n\n\n");
		}
	}

	public static OMElement createPayLoad() {
		OMFactory fac = OMAbstractFactory.getOMFactory();
		OMNamespace omNs = fac.createOMNamespace("urn:MCSoapClasses", "ns1");
		OMElement method = fac.createOMElement("TSoapCreateSessionID__mcsResult", omNs);
		OMElement soapResult = fac.createOMElement("SoapResult", omNs);
		OMElement sessionID = fac.createOMElement("SessionID", omNs);
		method.addChild(sessionID);
		method.addChild(soapResult);
		return method;
	}
}
Problemm is I'm not sure about createPayLoad() method because I can't find description how to write similar methods to the given wsdl. When I running the client sample I get following exception:
[INFO] Unable to sendViaPost to url[http://10.0.5.208:6090/soap/IMapCenterService]
java.net.SocketException: Software caused connection abort: recv failed
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.read(SocketInputStream.java:129)
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
	at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
	at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
	at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
	at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413)
	at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
	at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
	at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
	at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
	at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
	at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:542)
	at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:189)
	at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
	at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:371)
	at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:209)
	at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:448)
	at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:401)
	at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
	at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
	at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:548)
	at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:528)
	at org.hertz.test.MapCenterTest.main(MapCenterTest.java:21)
org.apache.axis2.AxisFault: Software caused connection abort: recv failed
	at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
	at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193)
	at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
	at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:371)
	at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:209)
	at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:448)
	at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:401)
	at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
	at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
	at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:548)
	at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:528)
	at org.hertz.test.MapCenterTest.main(MapCenterTest.java:21)
Caused by: java.net.SocketException: Software caused connection abort: recv failed
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.read(SocketInputStream.java:129)
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
	at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
	at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
	at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
	at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413)
	at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
	at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
	at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
	at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
	at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
	at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:542)
	at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:189)
	... 10 more
I'm the beginner in web service. My friend told axis2 is very good framework so I try to use it. For now without results. Please Help if You have some idea's.

--
Have a nice day
Martin.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 20 2008
Added on Oct 23 2008
1 comment
1,454 views