解决方案 »

  1.   

    公司已经有在servicesweb.asmx上有发送传真的接口了  就是让我去调用这个接口实现发送接收功能的
      

  2.   

    你你就 调用webservice  传参数。
      

  3.   


        private boolean sendRtxNotify(String receiver, String title, int time, String content)
            throws AxisFault
        {
            RPCServiceClient serviceClient = new RPCServiceClient();
            // 设置参数
            Options options = serviceClient.getOptions();
            // 设置调用的方�?
            options.setAction( "SendNotify");
            options.setTimeOutInMilliSeconds(600000L);
            // 远程webservice服务地址
            EndpointReference targetEPR = new EndpointReference("http://191.168.0.249/rtxapi.asmx" );
            options.setTo(targetEPR);
            options.setTimeOutInMilliSeconds(60000);
            // 调用远程方法的参�?
            Object[] opAddEntryArgs = new Object[] {receiver, title, time, content};
            // 返回结果类型
            Class[] classes = new Class[] {boolean. class};
            serviceClient.setTargetEPR(targetEPR);
            // 此处的是 实现类所在的包的倒序
            QName opAddEntry = new QName("http://tempuri.org/" , "SendNotify" );
            boolean str = (boolean)serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, classes)[0];
            System. out.println(str + "=================" );
            serviceClient.cleanupTransport();
            return str;
        }
       
        private boolean sendRtxNotify1(String receiver, String title, int time, String content)
            throws RemoteException
        {
            RtxapiSoapStub serviceClient = new RtxapiSoapStub();
            serviceClient.setTimeout(60000);
            boolean str = serviceClient.sendNotify(receiver, title, time, content);
            return str;
        }
       
        private static boolean sendRtxNotify2(String receiver, String title, int time, String content)
            throws RemoteException, ServiceException, MalformedURLException
        {
            String endPoint = "http://191.168.0.249/rtxapi.asmx" ; // 服务地址
            String soapActionURI = "http://tempuri.org/SendNotify" ;
            Service service = new Service(); // 创建一个服务(service)调用(call)
            Call call = (Call)service.createCall(); // 通过service创建call对象
            call.setTargetEndpointAddress( new java.net.URL(endPoint)); // 设置service所在URL
           
            call.setOperationName( new QName("http://tempuri.org/" , "SendNotify" )); // 设置调用方法名称,http://ws.apache.org/axis2为目标命名空间
            call.addParameter( new QName("receiver" ,"xmlString" ), org.apache.axis.Constants.XSD_STRING , javax.xml.rpc.ParameterMode.IN ); // 设置参数,queryString为参数名
            call.addParameter( new QName("title" ,"xmlString" ), org.apache.axis.Constants.XSD_STRING , javax.xml.rpc.ParameterMode.IN ); // 设置第二个参数
            call.addParameter( new QName("time" ,"xmlInt" ), org.apache.axis.Constants.XSD_INTEGER , javax.xml.rpc.ParameterMode.IN ); // 设置第三个参数
            call.addParameter( new QName("content","xmlString" ), org.apache.axis.Constants.XSD_STRING , javax.xml.rpc.ParameterMode.IN ); // 设置第四个参数
            call.setUseSOAPAction( true);
            call.setSOAPActionURI(soapActionURI);
            call.setReturnType(org.apache.axis.Constants.XSD_BOOLEAN);
            call.setTimeout(600000);
            boolean result = (boolean)call.invoke(new Object[] {receiver, title, time, content});
            logger.info(String.format( "receiver=[%s],title=[%s],time=[%d],content=[%s] 发送结果=[%s]" ,
                receiver,
                title,
                time,
                content,
                result));
            return result;
        }
       
        private static boolean sendNotify(String receiver, String title, int time, String content)
            throws Exception
        {
            Document document = DocumentHelper.createDocument(); 
            Element root = DocumentHelper.createElement("soap:Envelope");
            root.addAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
            root.addAttribute( "xmlns:xsd", "http://www.w3.org/2001/XMLSchema" );
            root.addAttribute( "xmlns:soap", "http://schemas.xmlsoap.org/soap/envelope/" );
            document.add(root);
            //生成root的一个接点 
            Element category = DocumentHelper.createElement("soap:Body");
            root.add(category);
            //生产category的一个接点 
            Element method = category.addElement("SendNotify" ,"http://tempuri.org/" );
            method. addElement("receiver").addText(receiver);
            method. addElement("title").addText(title);
            method. addElement("time").addText( "0");
            method. addElement("content").addText(content);
           
            URL url = new URL("http://191.168.0.249/rtxapi.asmx" );
            URLConnection connection = url.openConnection();
            HttpURLConnection httpConn = (HttpURLConnection)connection;
            System. out.println(document.asXML());
            byte[] b = document.asXML().getBytes();
            // Set the appropriate HTTP parameters.
            httpConn.setRequestProperty( "Content-Length", String.valueOf(b.length));
            httpConn.setRequestProperty( "Content-Type", "text/xml; charset=utf-8" );
            httpConn.setRequestProperty( "SOAPAction", "http://tempuri.org/SendNotify" );
            httpConn.setRequestMethod( "POST");
            httpConn.setDoOutput( true);
            httpConn.setDoInput( true);
            OutputStream out = httpConn.getOutputStream();
            out.write(b);
            out.close();
            // Read the response and write it to standard out.
            InputStreamReader isr = new InputStreamReader(httpConn.getInputStream());
            BufferedReader in = new BufferedReader(isr);
            SAXReader reader = new SAXReader();
            Document resultDoc = reader.read(in);
            Element resultRoot = resultDoc.getRootElement();
            List rootList = resultRoot.selectNodes("/soap:Envelope/soap:Body/*[name()='SendNotifyResponse']/*[name()='SendNotifyResult']" );
            Element element = null; 
            String resu= null;
            // 循环此节点,并取出对应的文本信息 
            for (Object obj : rootList) { 
                element = (Element) obj; 
                resu = element.getTextTrim(); 
            }
            return "true" .equals(resu);
        }
      

  4.   

    看不懂哇现在我只有一个asmx的内网地址  里面有一些方法  不知道该咋弄
      

  5.   

    参考 public static void main(String[] args) {
          try {
          String endpoint = "http://www.webxml.com.cn/WebServices/WeatherWS.asmx";
          Service service = new Service();
          Call call;
          call = (Call) service.createCall();
          call.setTargetEndpointAddress(new java.net.URL(endpoint));
          call.setOperationName(new QName("http://WebXml.com.cn/","getWeather"));
        
          call.setReturnClass(java.lang.String[].class);
          call.addParameter(new QName("http://WebXml.com.cn/", "theCityCode"),
          org.apache.axis.encoding.XMLType.XSD_STRING,
          javax.xml.rpc.ParameterMode.IN);
          call.addParameter(new QName("http://WebXml.com.cn/", "theUserID"),
          org.apache.axis.encoding.XMLType.XSD_STRING,
          javax.xml.rpc.ParameterMode.IN);      call.setUseSOAPAction(true);
          call.setSOAPActionURI("http://WebXml.com.cn/getWeather");
          String[] results = (String[]) call.invoke(new Object[] { "", "" });
          if (null != results) {
          for (int i = 0; i < results.length; i++) {
          System.out.println(results[i]);
          }
          }
        
          } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          } }