You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by yulinxp <yu...@gmail.com> on 2008/03/02 04:24:52 UTC

Re: How to seperate with CXF

Using the ClassLoader, it does load in sun's jar. But there is some runtime
exception complaining:
Exception in thread "main" java.lang.NoSuchMethodError:
com.sun.xml.bind.api.JAXBRIContext.newInstance([Ljava/lang/Class;Ljava/util/Collection;Ljava/util/Map;Ljava/lang/String;ZLcom/sun/xml/bind/v2/model/annotation/RuntimeAnnotationReader;)Lcom/sun/xml/bind/api/JAXBRIContext;
I guess this is not a right solution for me.

I tried CXF client. I can connect to the server after setting
allowChunking(false) and SSL.
But there comes another exception. The result is null.

org.apache.cxf.binding.soap.SoapFault: Error reading XMLStreamReader.
	at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:187)
	at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:56)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:207)
	at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:402)
	at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1948)
	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)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:207)
	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
	at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
	at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
	at $Proxy27.getRequestIDsNDA(Unknown Source)
	at
https.mdf_ingenixmedpoint_com.mdfwebservices.hprequest.HPRequestWSSoap_HPRequestWSSoap_Client.main(HPRequestWSSoap_HPRequestWSSoap_Client.java:82)
Caused by: com.ctc.wstx.exc.WstxParsingException: Received event DTD,
instead of START_ELEMENT or END_ELEMENT.
 at [row,col {unknown-source}]: [1,89]
	at
com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:605)
	at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:461)
	at com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1113)
	at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:85)
	... 15 more

Here is my source.

public final class HPRequestWSSoap_HPRequestWSSoap_Client {

    private static final QName SERVICE_NAME = new
QName("https://mdf.ingenixmedpoint.com/MDFWebServices/HPRequest.asmx",
"HPRequestWS");

    private HPRequestWSSoap_HPRequestWSSoap_Client() {
    }

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

    	int sourceID =1234;
    	String strXML = xmlFile2String("C://test.xml");
    	
        HPRequestWS ss = new HPRequestWS();
        HPRequestWSSoap port = ss.getHPRequestWSSoap();  

        org.apache.cxf.endpoint.Client client = ClientProxy.getClient(port);
        HTTPConduit httpConduit = (HTTPConduit) client.getConduit();  
        httpConduit.getClient().setAllowChunking(false); 
        
        TLSClientParameters tlsParams = new TLSClientParameters();
        tlsParams.setSecureSocketProtocol("SSL");
        httpConduit.setTlsClientParameters(tlsParams);         
        
        {
        	System.out.println("Invoking getRequestIDsNDA...");


        	javax.xml.ws.Holder<java.lang.Boolean> result = new
javax.xml.ws.Holder<java.lang.Boolean>();
        	javax.xml.ws.Holder<java.lang.String> response = new
javax.xml.ws.Holder<java.lang.String>();
            try{
            	port.getRequestIDsNDA(sourceID, strXML, result, response);
            	
            } catch (SOAPFaultException e) {
        		System.out.println(e.getMessage());

	        } catch (Exception e1) {
	        	e1.printStackTrace();
	        }
            
        	System.out.println("result=" + result.value);
        	System.out.println("response=" + response.value);

        } 
        
        System.exit(0);
    }

    public static String xmlFile2String(String fileName)
    {
      try{
        DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();
        InputSource inputSource = new InputSource(fileName);
        Document document =
documentBuilderFactory.newDocumentBuilder().parse(inputSource);
        StringWriter sw = new StringWriter();
        Transformer serializer =
TransformerFactory.newInstance().newTransformer();
        serializer.transform(new DOMSource(document), new StreamResult(sw));
        return sw.toString();
      }
      catch (Exception e) {
        e.printStackTrace();
      }
      
      return "";
    }  

//test.xml
<?xml version="1.0" encoding="UTF-8"?>
<mdf-get-request>
    <user-name>myUser</user-name>
    <user-password>myPassword</user-password>
    <source-id>1234</source-id>
    <id-count>1</id-count>
</mdf-get-request>
-- 
View this message in context: http://www.nabble.com/How-to-seperate-with-CXF-tp15765424p15784001.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: How to seperate with CXF

Posted by yulinxp <yu...@gmail.com>.
Thank you so much for the help. 
Now There are three solutions.

1)use CXF client with the setAllowChunking(false) and cypher suits

2) Use ClassLoader to use JAX-WS RI, and update jaxb-api.jar jax-impl.jar
jaxws-api.jar with Metro's version

3)update existing CXF server service to use Simple Frontend+Aegis instead of
JAX-WS Frontend/JAXB, 
remove cxf-rt-frontend-jaxws.jar


-- 
View this message in context: http://www.nabble.com/How-to-seperate-with-CXF-tp15765424p15797937.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: How to seperate with CXF

Posted by Daniel Kulp <dk...@apache.org>.


On Saturday 01 March 2008, yulinxp wrote:

> I tried CXF client. I can connect to the server after setting
> allowChunking(false) and SSL.
> But there comes another exception. The result is null.

Did some debugging and apparently the server isn't liking any of the 
cypher suites we have set and is sending back an HTML page instead of a 
nice soap fault or something.  This probably relates to:
https://issues.apache.org/jira/browse/CXF-1456

Change the code for the TLS params to:

        TLSClientParameters tlsParams = new TLSClientParameters();
        tlsParams.setSecureSocketProtocol("SSL");
        tlsParams.getCipherSuites().add("SSL_RSA_WITH_3DES_EDE_CBC_SHA");
        tlsParams.getCipherSuites().add("SSL_RSA_WITH_RC4_128_MD5");
        httpConduit.setTlsClientParameters(tlsParams);

and it connects fine.   I now get back a proper soap message and 
a "Invalid SourceID, username or password." response.

Dan




>
> org.apache.cxf.binding.soap.SoapFault: Error reading XMLStreamReader.
> 	at
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleM
>essage(ReadHeadersInterceptor.java:187) at
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleM
>essage(ReadHeadersInterceptor.java:56) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercepto
>rChain.java:207) at
> org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:402) at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRe
>sponse(HTTPConduit.java:1948) at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HT
>TPConduit.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$MessageSenderEndin
>gInterceptor.handleMessage(MessageSenderInterceptor.java:62) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercepto
>rChain.java:207) at
> org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254) at
> org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205) at
> org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) at
> org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135
>) at $Proxy27.getRequestIDsNDA(Unknown Source)
> 	at
> https.mdf_ingenixmedpoint_com.mdfwebservices.hprequest.HPRequestWSSoap
>_HPRequestWSSoap_Client.main(HPRequestWSSoap_HPRequestWSSoap_Client.jav
>a:82) Caused by: com.ctc.wstx.exc.WstxParsingException: Received event
> DTD, instead of START_ELEMENT or END_ELEMENT.
>  at [row,col {unknown-source}]: [1,89]
> 	at
> com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java
>:605) at
> com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:461)
> at
> com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1113)
> at
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleM
>essage(ReadHeadersInterceptor.java:85) ... 15 more
>
> Here is my source.
>
> public final class HPRequestWSSoap_HPRequestWSSoap_Client {
>
>     private static final QName SERVICE_NAME = new
> QName("https://mdf.ingenixmedpoint.com/MDFWebServices/HPRequest.asmx",
> "HPRequestWS");
>
>     private HPRequestWSSoap_HPRequestWSSoap_Client() {
>     }
>
>     public static void main(String args[]) throws Exception {
>
>     	int sourceID =1234;
>     	String strXML = xmlFile2String("C://test.xml");
>
>         HPRequestWS ss = new HPRequestWS();
>         HPRequestWSSoap port = ss.getHPRequestWSSoap();
>
>         org.apache.cxf.endpoint.Client client =
> ClientProxy.getClient(port); HTTPConduit httpConduit = (HTTPConduit)
> client.getConduit(); httpConduit.getClient().setAllowChunking(false);
>
>         TLSClientParameters tlsParams = new TLSClientParameters();
>         tlsParams.setSecureSocketProtocol("SSL");
>         httpConduit.setTlsClientParameters(tlsParams);
>
>         {
>         	System.out.println("Invoking getRequestIDsNDA...");
>
>
>         	javax.xml.ws.Holder<java.lang.Boolean> result = new
> javax.xml.ws.Holder<java.lang.Boolean>();
>         	javax.xml.ws.Holder<java.lang.String> response = new
> javax.xml.ws.Holder<java.lang.String>();
>             try{
>             	port.getRequestIDsNDA(sourceID, strXML, result,
> response);
>
>             } catch (SOAPFaultException e) {
>         		System.out.println(e.getMessage());
>
> 	        } catch (Exception e1) {
> 	        	e1.printStackTrace();
> 	        }
>
>         	System.out.println("result=" + result.value);
>         	System.out.println("response=" + response.value);
>
>         }
>
>         System.exit(0);
>     }
>
>     public static String xmlFile2String(String fileName)
>     {
>       try{
>         DocumentBuilderFactory documentBuilderFactory =
> DocumentBuilderFactory.newInstance();
>         InputSource inputSource = new InputSource(fileName);
>         Document document =
> documentBuilderFactory.newDocumentBuilder().parse(inputSource);
>         StringWriter sw = new StringWriter();
>         Transformer serializer =
> TransformerFactory.newInstance().newTransformer();
>         serializer.transform(new DOMSource(document), new
> StreamResult(sw)); return sw.toString();
>       }
>       catch (Exception e) {
>         e.printStackTrace();
>       }
>
>       return "";
>     }
>
> //test.xml
> <?xml version="1.0" encoding="UTF-8"?>
> <mdf-get-request>
>     <user-name>myUser</user-name>
>     <user-password>myPassword</user-password>
>     <source-id>1234</source-id>
>     <id-count>1</id-count>
> </mdf-get-request>



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog