2010-01-13 95 views

回答

1

是的,您可以使用org.apache.axis2.client.ServiceClient「adhoc」客戶端。它看起來像這樣。

import org.apache.axis2.client.ServiceClient; 
import org.apache.axiom.om.OMAbstractFactory; 
import org.apache.axiom.om.OMContainer; 
import org.apache.axiom.om.OMElement; 
import org.apache.axiom.om.OMFactory; 
import org.apache.axiom.om.OMNamespace; 
import java.net.URL; 


... 
String endpoint = "http://wsendpoint.com/ServiceName" 
QName operation = new QName("http://namespace","WsRequest");    
      OMElement payload = buildPayload("requestdata"); 


try{ 
        ServiceClient sender= new ServiceClient(
          null, 
          new URL(endpoint), 
          null, 
          null); 
        OMElement result = sender.sendReceive(operation,payload); 
      logger.debug("response is:" + result.toString());         

        } 

      }catch (Exception e) { 
       logger.debug("exception caught: " + e.getMessage()); 
      } 
相關問題