axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kumuda Bhaskar" <Kumuda.Bhas...@symphonysv.com>
Subject RE: [Axis2]-.Net I hope somebody will surely help me this time.
Date Thu, 29 Sep 2005 09:42:23 GMT
Hi Deepal,

 

As you said, I added the code shown in Bold letters and tried, still I
am getting the same Exception

I will next try with InOutMepClient

 

 

public static MessageContext getMessageContext(QName opName,
OperationDescription opdesc) throws Exception{

            OMElement operation;

        MessageContext msgContext = null;

        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();

        SOAPEnvelope envelope = factory.getDefaultEnvelope();

 
//envelope.declareNamespace("http://schemas.xmlsoap.org/soap/envelope/",
"soap");

 
envelope.declareNamespace("http://schemas.xmlsoap.org/ws/2004/03/address
ing", "wsa");

        

        OMNamespace wsns =
factory.createOMNamespace("http://schemas.xmlsoap.org/ws/2004/03/address
ing","wsa");

        OMElement wsaAction = factory.createOMElement("Action", wsns);

 
wsaAction.addChild(factory.createText("http://stockservice.contoso.com/w
se/samples/2003/06/Concat"));

        OMElement wsaMessageId = factory.createOMElement("MessageID",
wsns);

 
wsaMessageId.addChild(factory.createText("uuid:b6272374-e72a-464d-8af2-7
6199b15aea1"));

        OMElement wsareplyTo = factory.createOMElement("ReplyTo", wsns);

        OMElement wsaaddress = factory.createOMElement("Address", wsns);

 
wsaaddress.addChild(factory.createText("http://schemas.xmlsoap.org/ws/20
04/03/addressing/role/anonymous"));

        wsareplyTo.addChild(wsaaddress);

        OMElement wsaTo = factory.createOMElement("To", wsns);

 
wsaTo.addChild(factory.createText("soap://stockservice.contoso.com/wse/s
amples/2003/06/TcpSyncStockService"));

        

        envelope.getHeader().addChild(wsaAction);

        envelope.getHeader().addChild(wsaMessageId);

        envelope.getHeader().addChild(wsareplyTo);

        envelope.getHeader().addChild(wsaTo);

        

 
envelope.declareNamespace("http://www.w3.org/2001/XMLSchema-instance",
"xmlns");

        OMNamespace ns1 =
factory.createOMNamespace("http://stockservice.contoso.com/wse/samples/2
003/06/Concat","v");

        operation = factory.createOMElement("Concat", ns1);

        OMElement first = factory.createOMElement("FirstStr",ns1);

        first.addChild(factory.createText("Hello ") );

        OMElement sec = factory.createOMElement("SecondStr",ns1);

        sec.addChild(factory.createText(" World") );

        operation.addChild(first);

        operation.addChild(sec);

        envelope.getBody().addChild(operation);

        ConfigurationContextFactory fac = new
ConfigurationContextFactory();

        ConfigurationContext configContext =
fac.buildClientConfigurationContext("Concat");

        try {

            msgContext = new MessageContext(configContext);

            

            ServiceDescription service = new ServiceDescription(opName);

            service.addOperation(opdesc);

            configContext.getAxisConfiguration().addService(service);

            msgContext.setServiceDescription(service);

            msgContext.setOperationDescription(opdesc);

        } catch (AxisFault axisFault) {

            axisFault.printStackTrace();

        }

        msgContext.setEnvelope(envelope);

        return msgContext;

    }

 

Exception got : 

org.apache.axis2.AxisFault: null; nested exception is: 

      javax.xml.stream.XMLStreamException

      at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUti
ls.java:97)

      at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUti
ls.java:47)

      at
org.apache.axis2.clientapi.TwoWayTransportBasedSender.send(TwoWayTranspo
rtBasedSender.java:53)

      at
org.apache.axis2.clientapi.InOutMEPClient.invokeBlocking(InOutMEPClient.
java:177)

      at com.hyperion.tcp.TCPClient.main(TCPClient.java:47)

Caused by: javax.xml.stream.XMLStreamException

      at com.bea.xml.stream.MXParser.checkForXMLDecl(MXParser.java:712)

      at com.bea.xml.stream.MXParser.setInput(MXParser.java:721)

      at
com.bea.xml.stream.MXParserFactory.createXMLStreamReader(MXParserFactory
.java:235)

      at
com.bea.xml.stream.MXParserFactory.createXMLStreamReader(MXParserFactory
.java:64)

      at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUti
ls.java:89)

      ... 4 more

Exception in thread "main"

________________________________

From: Deepal Jayasinghe [mailto:deepal@opensource.lk] 
Sent: Thursday, September 29, 2005 2:58 PM
To: axis-user@ws.apache.org
Subject: Re: [Axis2]-.Net I hope somebody will surely help me this time.

 

Hi Kumuda;

 

Why do you try to use  call.invokeBlocking(opdesc, requestContext); , if
it is only to give SOAPEnvelop there is a method in InOutMepClient to do
so

 

If you really want to give your messageContext and do the invocation you
have to follow some more steps;

 

        MessageContext requestContext = new
MessageContext(configContext);
        ServiceDescription srevice = new
ServiceDescription(serviceName);
        srevice.addOperation(opdesc);
        configContext.getAxisConfiguration().addService(srevice);
        requestContext.setServiceDescription(service);
        requestContext.setOperationDescription(opdesc);

 

Please try to do the same invocation by including those lines in your
code , if you still have the problem please let me know


Thanks,
 Deepal
................................................................
~Future is Open~

	----- Original Message ----- 

	From: Kumuda Bhaskar <mailto:Kumuda.Bhaskar@symphonysv.com>  

	To: axis-user@ws.apache.org 

	Sent: Thursday, September 29, 2005 1:03 PM

	Subject: RE: [Axis2]-.Net I hope somebody will surely help me
this time.

	 

	Hi Deepal,

	 

	Thank you very much Deepal, I will create the JIRA issue also. I
hope, It will get resolved soon and will be informed.

	 

	Thanks and Regards

	KumudaRajarshi

	 

	
________________________________


	From: Deepal Jayasinghe [mailto:deepal@opensource.lk] 
	Sent: Wednesday, September 28, 2005 5:23 PM
	To: axis-user@ws.apache.org
	Subject: Re: [Axis2]-.Net I hope somebody will surely help me
this time.

	 

	Hi Kumoda;

	 

	You have got that problem due to your Inputstream is null and
you re trying to create SOAPMessage out of that , and the problem is not
in your code it in Axis2 side . We have found the problem it is due to
transport receivers problem we will fix that soon , if you can please
create a JIRA issue too.

	
	Thanks,
	 Deepal
	................................................................
	~Future is Open~

		----- Original Message ----- 

		From: Kumuda Bhaskar
<mailto:Kumuda.Bhaskar@symphonysv.com>  

		To: axis-user@ws.apache.org 

		Sent: Wednesday, September 28, 2005 3:19 PM

		Subject: [Axis2]-.Net I hope somebody will surely help
me this time.

		 

		Hi,

		I was trying to call the .Net webservice from Axis2
client. I am using axis2-0.92 the latest....

		I am getting the following Exception

		org.apache.axis2.AxisFault: null; nested exception is: 

		      javax.xml.stream.XMLStreamException

		      at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUti
ls.java:97)

		      at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUti
ls.java:47)

		      at
org.apache.axis2.clientapi.TwoWayTransportBasedSender.send(TwoWayTranspo
rtBasedSender.java:53)

		      at
org.apache.axis2.clientapi.InOutMEPClient.invokeBlocking(InOutMEPClient.
java:177)

		      at
com.hyperion.tcp.TCPClient.main(TCPClient.java:46)

		Caused by: javax.xml.stream.XMLStreamException

		      at
com.bea.xml.stream.MXParser.checkForXMLDecl(MXParser.java:712)

		      at
com.bea.xml.stream.MXParser.setInput(MXParser.java:721)

		      at
com.bea.xml.stream.MXParserFactory.createXMLStreamReader(MXParserFactory
.java:235)

		      at
com.bea.xml.stream.MXParserFactory.createXMLStreamReader(MXParserFactory
.java:64)

		      at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUti
ls.java:89)

		      ... 4 more

		Exception in thread "main"

		 

		From port peeker, I found that the xml that is being
created by Axis2 client is

		 

		<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"><soapenv:He
ader><wsa:Action>http://stockservice.contoso.com/wse/samples/2003/06/Con
cat</wsa:Action><wsa:MessageID>uuid:b6272374-e72a-464d-8af2-76199b15aea1
</wsa:MessageID><wsa:ReplyTo><wsa:Address>http://schemas.xmlsoap.org/ws/
2004/03/addressing/role/anonymous</wsa:Address></wsa:ReplyTo><wsa:To>soa
p://stockservice.contoso.com/wse/samples/2003/06/TcpSyncStockService</ws
a:To></soapenv:Header><soapenv:Body><v:Concat
xmlns:v="http://stockservice.contoso.com/wse/samples/2003/06/Concat"><v:
FirstStr>Hello </v:FirstStr><v:SecondStr>
World</v:SecondStr></v:Concat></soapenv:Body></soapenv:Envelope>

		 

		Axis2 client souce code is as follows

		/*

		 * Copyright 2004,2005 The Apache Software Foundation.

		 *

		 * Licensed under the Apache License, Version 2.0 (the
"License");

		 * you may not use this file except in compliance with
the License.

		 * You may obtain a copy of the License at

		 *

		 *      http://www.apache.org/licenses/LICENSE-2.0

		 *

		 * Unless required by applicable law or agreed to in
writing, software

		 * distributed under the License is distributed on an
"AS IS" BASIS,

		 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied.

		 * See the License for the specific language governing
permissions and

		 * limitations under the License.

		 */

		package com.hyperion.hfm.acistcptest;

		 

		import org.apache.axis2.AxisFault;

		import org.apache.axis2.Constants;

		import org.apache.axis2.addressing.EndpointReference;

		import org.apache.axis2.clientapi.Call;

		import org.apache.axis2.context.ConfigurationContext;

		import
org.apache.axis2.context.ConfigurationContextFactory;

		import org.apache.axis2.context.MessageContext;

		import org.apache.axis2.context.ServiceContext;

		import
org.apache.axis2.description.OperationDescription;

		import org.apache.axis2.description.ServiceDescription;

		import
org.apache.axis2.description.TransportOutDescription;

		import org.apache.axis2.soap.SOAPEnvelope;

		import org.apache.axis2.soap.SOAPFactory;

		import org.apache.axis2.transport.TransportSender;

		import
org.apache.axis2.transport.tcp.TCPTransportSender;

		import org.apache.axis2.engine.AxisConfigurationImpl;

		import org.apache.axis2.addressing.om.AddressingHeaders;

		import org.apache.axis2.om.OMAbstractFactory;

		import org.apache.axis2.om.OMDocument;

		import org.apache.axis2.om.OMElement;

		import org.apache.axis2.om.OMFactory;

		import org.apache.axis2.om.OMNamespace;

		import org.apache.axis2.addressing.om.*;

		import javax.xml.namespace.QName;

		import org.apache.axis2.clientapi.MessageSender;

		 

		import javax.xml.stream.FactoryConfigurationError;

		import javax.xml.stream.XMLOutputFactory;

		import javax.xml.stream.XMLStreamException;

		import javax.xml.stream.XMLStreamWriter;

		 

		/**

		 * This is a Client progam that accesses 'MyService' web
service in Axis2 samples

		 */

		public class AxisClient {

		 

		    private static String toEpr =
"soap.tcp://blrl2790:2342/StockService";

		 

		    public static void main(String[] args) throws
AxisFault {

		 

		            EndpointReference wsaTo = new
EndpointReference("soap://stockservice.contoso.com/wse/samples/2003/06/T
cpSyncStockService");

		            AddressingHeaders headers = new
AddressingHeaders(wsaTo,
"http://stockservice.contoso.com/wse/samples/2003/06/StockQuoteRequest")
;

		            

		            

		            MessageContext requestContext = null; 

		                        //FaxReceive.request(new
TFaxReceive(account, password));

		 

		        QName opName = new
QName("soap://stockservice.contoso.com/wse/samples/2003/06/TcpSyncStockS
ervice", "GetStockQuotes");

		 

		        OperationDescription opdesc = new
OperationDescription(opName);

		            

		            EndpointReference targetEPR = new
EndpointReference(toEpr);

		            org.apache.axis2.clientapi.Call call = new
org.apache.axis2.clientapi.Call();

		            call.setTo(targetEPR);

		    

		            call.engageModule(new
QName(Constants.MODULE_ADDRESSING));

		    

	
call.setWsaAction("http://stockservice.contoso.com/wse/samples/2003/06/S
tockQuoteRequest");

		            

	
call.setTransportInfo(Constants.TRANSPORT_TCP, Constants.TRANSPORT_TCP,
false);

		 

		            ConfigurationContextFactory fac = new
ConfigurationContextFactory();

		 

		        ConfigurationContext configContext =
fac.buildClientConfigurationContext("StockQuoteRequest");

		 

		        try {

		 

		            requestContext = new
MessageContext(configContext);

		 

		        } catch (AxisFault axisFault) {

		 

		            axisFault.printStackTrace();

		 

		        }

		        SOAPFactory factory =
OMAbstractFactory.getSOAP11Factory();

		        OMNamespace ns1 =
factory.createOMNamespace("http://stockservice.contoso.com/wse/samples/2
003/06","NS1");

		 

		        SOAPEnvelope envelope =
factory.getDefaultEnvelope();

		        OMElement operation =
factory.createOMElement("StockQuoteRequest",ns1);

		        envelope.getBody().addChild(operation);

		        OMElement first =
factory.createOMElement("symbols", ns1);

		        //OMElement second =
fac.createOMElement("Symbol");

		        OMElement value =
factory.createOMElement("Symbol", ns1);

		        value.addChild(factory.createText(value,
"FABRIKAM"));

		        first.addChild(value);

		        operation.addChild(first);

		        requestContext.setEnvelope(envelope);

		            

		            call.invokeBlocking(opdesc, requestContext);

		            //OMElement result =

		              //      (OMElement)
call.invokeBlocking("GetStockQuotes", getPayload());

		            //call.close();

		 

		    

		            /*OMFactory fac =
OMAbstractFactory.getOMFactory();

		            String tryThisNamespace =
"http://stockservice.contoso.com/wse/samples/2003/06/tryThis";

		        OMNamespace omNs =
fac.createOMNamespace(tryThisNamespace, "xmlns");

		        OMElement method =
fac.createOMElement("tryThis", omNs);

		        OMElement value = fac.createOMElement("Text",
omNs);

		        value.addChild(fac.createText(value, "Axis2 Ping
String "));

		        method.addChild(value);

		        MessageSender msgSender = new MessageSender();

		        msgSender.setTo(targetEPR);

	
msgSender.setSenderTransport(Constants.TRANSPORT_TCP);

		        msgSender.engageModule(new
QName(Constants.MODULE_ADDRESSING));

		        

		        msgSender.setWsaAction(tryThisNamespace);

		    

		        msgSender.send("tryThis", method);

		*/

		        

		            /*TCPTransportSender sender = new
TCPTransportSender();

		        sender.startSendWithToAddress(new
MessageContext(), new OutputStream)

		        

		        sender.finalizeSendWithToAddress(new
MessageContext(), )

		            Call call = new Call();

		        call.setTo(new EndpointReference(toEpr));

		        call.setTransportInfo(Constants.TRANSPORT_TCP,

		                Constants.TRANSPORT_TCP,

		                false);*/

		        //call.engageModule(new
QName(Constants.MODULE_ADDRESSING));

		        

		        

		        

		 

		        

		        

		       /*OMElement result = call.invokeBlocking("echo",
getPayload());

		        //OMElement result = call.i("echo",
getPayload());

		        

		        try {

		            XMLStreamWriter writer =
XMLOutputFactory.newInstance()

		                    .createXMLStreamWriter(System.out);

		            result.serializeWithCache(writer);

		            writer.flush();

		        } catch (XMLStreamException e) {

		            e.printStackTrace();

		        } catch (FactoryConfigurationError e) {

		            e.printStackTrace();

		        }*/

		    }

		 

		 

		    private static OMElement getPayload() {

		        OMFactory fac =
OMAbstractFactory.getOMFactory();

		        OMDocument doc = fac.createOMDocument();

		        String tryThisNamespace =
"http://stockservice.contoso.com/wse/samples/2003/06/tryThis";

		        OMNamespace omNs = fac.createOMNamespace(

	
"http://stockservice.contoso.com/wse/samples/2003/06",
"StockQuoteRequest");

		        //OMNamespace omNs =
fac.createOMNamespace(tryThisNamespace, "v");

		        //OMElement method =
fac.createOMElement("tryThis", omNs);

		        OMElement method =
fac.createOMElement("StockQuoteRequest", omNs);

		        OMElement first = fac.createOMElement("symbols",
omNs);

		        //OMElement second =
fac.createOMElement("Symbol");

		        OMElement value = fac.createOMElement("Symbol",
omNs);

		        value.addChild(fac.createText(value,
"FABRIKAM"));

		        first.addChild(value);

		        method.addChild(first);

		        //doc.setDocumentElement(method);

		        //return  doc.getDocumentElement();

		        return method;

		    }

		 }

		 


Mime
View raw message