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 [Axis2]-.Net I hope somebody will surely help me this time.
Date Wed, 28 Sep 2005 09:19:10 GMT
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