| |

VerySource

 Forgot password?
 Register
Search
View: 641|Reply: 1

Java call .net webservice throws SAXNotRecognizedException? ? Please master help! !!

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-5 12:30:01
| Show all posts |Read mode
Code:
 String endpoint = "http: //localhost/WebServiceTest/Service1.asmx";
 Service service = new Service ();
 Call call = (Call) service.createCall ();
 call.setTargetEndpointAddress (new java.net.URL (endpoint));
 call.setOperationName (new QName ("http://tempuri.org/", "HelloWorld"));
 call.setReturnType (XMLType.XSD_STRING);
 String res = (String) call.invoke (new Object [] {});
 System.out.println (res);

abnormal:
Exception in thread "main" AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString: org.xml.sax.SAXNotRecognizedException: Feature: http://xml.org/sax/properties/lexical-handler
 faultActor:
 faultNode:
 faultDetail:
{http://xml.apache.org/axis/}stackTrace: org.xml.sax.SAXNotRecognizedException: Feature: http://xml.org/sax/properties/lexical-handler
at org.apache.xerces.jaxp.SAXParserImpl.setProperty (SAXParserImpl.java:155)
at org.apache.axis.encoding.DeserializationContextImpl.parse (DeserializationContextImpl.java:241)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope (SOAPPart.java:538)
at org.apache.axis.Message.getSOAPEnvelope (Message.java:376)
at org.apache.axis.client.Call.invokeEngine (Call.java:2583)
at org.apache.axis.client.Call.invoke (Call.java:2553)
at org.apache.axis.client.Call.invoke (Call.java:2248)
at org.apache.axis.client.Call.invoke (Call.java:2171)
at org.apache.axis.client.Call.invoke (Call.java:1691)
at com.dawen.cooperate.TestClient.main (TestClient.java:25)


org.xml.sax.SAXNotRecognizedException: Feature: http://xml.org/sax/properties/lexical-handler
at org.apache.axis.AxisFault.makeFault (AxisFault.java:129)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope (SOAPPart.java:543)
at org.apache.axis.Message.getSOAPEnvelope (Message.java:376)
at org.apache.axis.client.Call.invokeEngine (Call.java:2583)
at org.apache.axis.client.Call.invoke (Call.java:2553)
at org.apache.axis.client.Call.invoke (Call.java:2248)
at org.apache.axis.client.Call.invoke (Call.java:2171)
at org.apache.axis.client.Call.invoke (Call.java:1691)
at com.dawen.cooperate.TestClient.main (TestClient.java:25)
Caused by: org.xml.sax.SAXNotRecognizedException: Feature: http://xml.org/sax/properties/lexical-handler
at org.apache.xerces.jaxp.SAXParserImpl.setProperty (SAXParserImpl.java:155)
at org.apache.axis.encoding.DeserializationContextImpl.parse (DeserializationContextImpl.java:241)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope (SOAPPart.java:538)
... 7 more
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 Japan

Post time: 2020-3-24 15:45:02
| Show all posts
import java.net.MalformedURLException;
import java.rmi.RemoteException;

import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;

You use this to see.

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;

public class AxisWSClient
{
    
    private String endpoint;
    private String qName;
    private String operationName;


    public AxisWSClient (String endpoint, String qName, String operationName)
    {
        this.endpoint = endpoint;
        this.qName = qName;
        this.operationName = operationName;
    }

    public Object getRemoteResult (Object [] inParam, Class outClazz) throws RemoteException
    {
        String endpoint = this.endpoint;
        String qName = this.qName;
        String operationName = this.operationName;

        Call call = null;
       
        //System.out.println("11111111111111 ");
        Object [] o = new Object [] {};
       
        try
        {
        Service service = new Service ();
            call = (Call) service.createCall ();
            call.setTargetEndpointAddress (new java.net.URL (endpoint));
            call.setOperationName (new QName (qName, operationName));

            if (inParam! = null)
                o = inParam;

            if (outClazz! = null)
            {
            String className = outClazz.getName ();
            int i = className.lastIndexOf (".") + 1;
            className = className.substring (i, className.length ());
            Ranch
                QName qn = new QName ("urn:" + className, className);
                call.registerTypeMapping (outClazz, qn, new BeanSerializerFactory (outClazz, qn),
                        new BeanDeserializerFactory (outClazz, qn));
            }
        }

        catch (MalformedURLException e)
        {
            e.printStackTrace ();
        }
        catch (Exception e)
        {
            e.printStackTrace ();
        }
        
        return call.invoke (o);
    }

    public Object getRemoteResult (Class inParamClazz, Class outClazz)
    {
        return null;
    }

    public Object getRemoteResult (Class inParamClazz)
    {
        return null;
    }

    public static void main (String args [])
    {

    / *
    * test string function
    * /
        / * AxisWSClient kc = new AxisWSClient ("http://127.0.0.1:7001/WebRoot/services/TestWS",
                "services.blackjack.ftyd.com", "testString");

        Object [] o = new Object []
        {new String ("shinhua")};
        
        try
        {
            String sr = (String) kc.getRemoteResult (o, null);
            System.out.println (sr);
        }
        catch (RemoteException e)
        {
            e.printStackTrace ();
        } * /
    Ranch
    Ranch
    }
    
}
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list