Axis1.4调用Cxf发布的webservice服务

 

webservice服务相关文件如
SheetStateSync.xml

 

实际调用代码如下

import java.rmi.RemoteException;

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

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;


public class Client {
    
    public static void main(String[] args) {

        String endPoint = "http://10.31.4.45:9000/SheetStateSync";
        Service service = new Service();
        try {
            Call call = (Call) service.createCall();
            call.setTargetEndpointAddress(endPoint);
            call.setOperationName(new QName("http://service.eoms.chinamobile.com/SheetStateSync", "syncSheetState"));

            call.addParameter(new QName("http://service.eoms.chinamobile.com/SheetStateSync", "serSupplier"), XMLType.XSD_STRING, ParameterMode.IN);
			call.addParameter(new QName("http://service.eoms.chinamobile.com/SheetStateSync", "serCaller"), XMLType.XSD_STRING, ParameterMode.IN);
			call.addParameter(new QName("http://service.eoms.chinamobile.com/SheetStateSync", "callerPwd"), XMLType.XSD_STRING, ParameterMode.IN);
			call.addParameter(new QName("http://service.eoms.chinamobile.com/SheetStateSync", "callTime"), XMLType.XSD_STRING, ParameterMode.IN);
			call.addParameter(new QName("http://service.eoms.chinamobile.com/SheetStateSync", "opDetail"), XMLType.XSD_STRING, ParameterMode.IN);

            String returnValue = (String) call.invoke(new Object[] {"boco1","boco1","boco1","boco1", getOpdetail()});

            System.out.println(returnValue);
            
        } catch (ServiceException e) {
            e.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
    
    private static String getOpdetail() {
    	return "<?xml version='1.0' encoding='GBK'?>"
				+ "\n<opDetail>"
				+ "\n  <recordInfo>"
				+ "\n    <fieldInfo>"
				+ "\n      <fieldEnName>alarmId</fieldEnName>"
				+ "\n      <fieldChName>网管告警ID</fieldChName>"
				+ "\n      <fieldContent>BOCO_WNMS_3596995728_2365773550_2810909194_1946027486</fieldContent>"
				+ "\n    </fieldInfo>"
				+ "\n    <fieldInfo>"
				+ "\n      <fieldEnName>sheetNo</fieldEnName>"
				+ "\n      <fieldChName>EOMS工单ID</fieldChName>"
				+ "\n      <fieldContent>FJ-051-130909-10011</fieldContent>"
				+ "\n    </fieldInfo>"
				+ "\n    <fieldInfo>"
				+ "\n      <fieldEnName>sheetStatus</fieldEnName>"
				+ "\n      <fieldChName>工单状态</fieldChName>"
				+ "\n      <fieldContent>待受理</fieldContent>"
				+ "\n    </fieldInfo>"
				+ "\n    <fieldInfo>"
				+ "\n      <fieldEnName>statusTime</fieldEnName>"
				+ "\n      <fieldChName>状态时间</fieldChName>"
				+ "\n      <fieldContent>2012-11-20 03:13:15</fieldContent>"
				+ "\n    </fieldInfo>"
				+ "\n    <fieldInfo>"
				+ "\n      <fieldEnName>region_id</fieldEnName>"
				+ "\n      <fieldChName>地市</fieldChName>"
				+ "\n      <fieldContent>11156</fieldContent>"
				+ "\n    </fieldInfo>"
				+ "\n    <fieldInfo>"
				+ "\n      <fieldEnName>DealMan</fieldEnName>"
				+ "\n      <fieldChName>当前步骤处理人</fieldChName>"
				+ "\n      <fieldContent>孙子琪</fieldContent>"
				+ "\n    </fieldInfo>"
				+ "\n  </recordInfo>"
				+ "\n</opDetail>";
    }

}

 

在服务侧,看到client提交的报文为

<?xml version="1.0" encoding="utf-8"?>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
    <ns1:syncSheetState xmlns:ns1="http://service.eoms.chinamobile.com/SheetStateSync" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <ns1:serSupplier xsi:type="xsd:string">boco1</ns1:serSupplier>
      <ns1:serCaller xsi:type="xsd:string">boco1</ns1:serCaller>
      <ns1:callerPwd xsi:type="xsd:string">boco1</ns1:callerPwd>
      <ns1:callTime xsi:type="xsd:string">boco1</ns1:callTime>
      <ns1:opDetail xsi:type="xsd:string">&lt;?xml version='1.0' encoding='GBK'?&gt; &lt;opDetail&gt; &lt;recordInfo&gt; &lt;fieldInfo&gt; &lt;fieldEnName&gt;alarmId&lt;/fieldEnName&gt; &lt;fieldChName&gt;网管告警ID&lt;/fieldChName&gt; &lt;fieldContent&gt;BOCO_WNMS_3596995728_2365773550_2810909194_1946027486&lt;/fieldContent&gt; &lt;/fieldInfo&gt; &lt;fieldInfo&gt; &lt;fieldEnName&gt;sheetNo&lt;/fieldEnName&gt; &lt;fieldChName&gt;EOMS工单ID&lt;/fieldChName&gt; &lt;fieldContent&gt;FJ-051-130909-10011&lt;/fieldContent&gt; &lt;/fieldInfo&gt; &lt;fieldInfo&gt; &lt;fieldEnName&gt;sheetStatus&lt;/fieldEnName&gt; &lt;fieldChName&gt;工单状态&lt;/fieldChName&gt; &lt;fieldContent&gt;待受理&lt;/fieldContent&gt; &lt;/fieldInfo&gt; &lt;fieldInfo&gt; &lt;fieldEnName&gt;statusTime&lt;/fieldEnName&gt; &lt;fieldChName&gt;状态时间&lt;/fieldChName&gt; &lt;fieldContent&gt;2012-11-20 03:13:15&lt;/fieldContent&gt; &lt;/fieldInfo&gt; &lt;fieldInfo&gt; &lt;fieldEnName&gt;region_id&lt;/fieldEnName&gt; &lt;fieldChName&gt;地市&lt;/fieldChName&gt; &lt;fieldContent&gt;11156&lt;/fieldContent&gt; &lt;/fieldInfo&gt; &lt;fieldInfo&gt; &lt;fieldEnName&gt;DealMan&lt;/fieldEnName&gt; &lt;fieldChName&gt;当前步骤处理人&lt;/fieldChName&gt; &lt;fieldContent&gt;孙子琪&lt;/fieldContent&gt; &lt;/fieldInfo&gt; &lt;/recordInfo&gt; &lt;/opDetail&gt;</ns1:opDetail>
    </ns1:syncSheetState>
  </soapenv:Body>
</soapenv:Envelope>

 

 

你可能感兴趣的:(webservice,axis1.4)