janrick 2022-01-28 13:52 采纳率: 33.3%
浏览 533
已结题

通过vpn连接的网络,访问webservice地址时报504错误

问题遇到的现象和发生背景

现在有台中转电脑,通过vpn可以访问内网,现在开发一个程序部署到该中转电脑上,访问webservice服务,不管是用Java还是用net都报504错误

问题相关代码,请勿粘贴截图
package com.jytj.service;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.File;
import java.io.IOException;
import org.dom4j.Document;
import com.xmlfile.*;

public class TestClient1 {
    public static void main(String[] args) throws Exception {
        String url = "http://127.0.0.1:8080/jytjRPCService/services/LisBaseService?wsdl";

        String namespace = "http://service.jytj.com";// 此处的命名空间 example
                                                        // 应与发布的服务中的命名空间保持一致.
        String operateName = "execute";
//        String operateName = "ws_execute";
        /**
         * 
         * uploadSampleType.xml 标本类型上传 getSampleType 标本类型下载 uploadKdxmTest
         * 开单项目上传 getHyxm 开单项目下载 uploadLabTest 检验报告项目上传 getJyxm 检验报告项目下载
         * uploadBioDict 细菌字典上传 uploadAntiDict 药敏字典上传 getDoctAdvise条码获取
         * submitReportBat检验报告单上传 cancelCheckFeedback取消审核反馈
         * receiveSampleFeedback标本接受反馈 sendSampleWarn危急值发布告知
         * sendSampleNoreport未及时报告告知 receiveReportFeedback报告已阅读反馈
         * getDeliveryList标本交接单查询 uploadPdfReport pdf文件上传
         * */
        String str1 = "";
        try {
            String configPath = TestClient1.class.getClassLoader()
                    .getResource("com/xmlfile/submitReportBat.xml").getFile();
            configPath = java.net.URLDecoder.decode(configPath, "utf-8");
            File file = new File(configPath);
            Document doc = XMLHelper.getDocument(file);
            str1 = doc.asXML();
            String[] param = new String[] { str1 };
            Axis2CommonClient axClient = new Axis2CommonClient();

            Object obj = axClient.excute(url, namespace, operateName, param);

            System.out.println(obj);

        } catch (Exception e) {

            e.printStackTrace();
        }
    }
}

package com.jytj.service;

import java.util.Iterator;



import javax.xml.namespace.QName;

 

import org.apache.axiom.om.OMElement;

import org.apache.axis2.addressing.EndpointReference;

import org.apache.axis2.client.Options;

import org.apache.axis2.rpc.client.RPCServiceClient;


public class Axis2CommonClient {
    public Axis2CommonClient() {


    }

     

    /**

    * 

    * @param srvcUrl

    *            访问的url

    * @param namespace

    *            命名空间

    * @param operateName

    *            你想调用的方法

    * @param param

    *            要传入的参数。

    * @return

    * @throws Exception

    */

    public Object excute(String srvcUrl, String namespace, String operateName,
    Object param[]) throws Exception {
        //namespce : http://com operateName :方法名
    QName qname = new QName(namespace, operateName);
    RPCServiceClient client = new RPCServiceClient();
    Options options = new Options();
    options.setTo(new EndpointReference(srvcUrl));
    options.setAction("urn:" + operateName);
    client.setOptions(options);
    OMElement element = client.invokeBlocking(qname, param);
    if (element != null && !"".equals(element)) {
    Iterator<?> values = element.getChildrenWithName(new QName(
    namespace, "return"));
    while (values.hasNext()) {
    OMElement omElement = (OMElement) values.next();
    return omElement.getText();
    }
    } else {
    return element;
    }
    return "-1";

    }
}


运行结果及报错内容

img

追加说明:
用soapui访问,也是报错,其实底层报的也是504错误

img

二、用net语言开发也是不行,

img


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WindowsFormsApplication2.WebReference;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                dispSoap();
            }
            catch (Exception ex)
            {

                this.textBox1.Text = ex.Message +  ex.StackTrace;
            }
        }

        private string dispSoap()
        {

            WebReference.LisBaseService service = new LisBaseService();
            string request = " <request action=\"submitReportBat\" client=\"生物\">"
                + "< body >" + "< datainfo >" +
    "< jgid > 4 </ jgid >" +
    "< sampleno > 200040009763 </ sampleno > " +
    "< doctadviseno > 200040009763 </ doctadviseno >" +
    "< receivetime > 2022 - 01 - 06 17:44:23 </ receivetime >" +
           "< receivername > 李 </ receivername >" +
           "< patientid > 045087195 </ patientid >" +
          " < patientname > 郑 </ patientname >" +
           "< sex > 1 </ sex >" +
          " < checkername > 李 </ checkername >" +
          " < checker2name > 彭 </ checker2name >" +
          " < checktime > 2022 - 01 - 07 11:30:29 </ checktime >" +
          "        < resultinfo >" +
              "        < testid > 1127 </ testid >" +
               "       < chinesename ></ chinesename >" +
                "      < wstestid > 1128 </ wstestid >" +
                 "     < wschinesename ></ wschinesename >" +
                  "    < testresult > 43.39 </ testresult >" +
                   "   < ckfw ></ ckfw >" +
                    "  < reflo ></ reflo >" +
                     " < refhi ></ refhi >" +
                      "< hint ></ hint >" +
                "      < unit ></ unit >" +
                "  </resultinfo >" +
                 " < PDFLIST >" +
                "      < PDFORDER > 1 </PDFORDER >" +
                 "     < PDF ></ PDF >" +
                 "     < PAGE > 2 </ PAGE >" +
                 " </ PDFLIST >" +
              "</datainfo >" +
                "         </body >" +
                 "      </request > ";
            service.Timeout = -1;

            textBox1.Text = service.UserAgent;
            textBox1.Text += service.Url;
            textBox1.Text += service.SoapVersion;
            textBox1.Text += service.Proxy;
            textBox1.Text += service.ClientCertificates;

           //service.executeAsync(request);
            string result = service.execute(request);

            //textBox1.Text = result;
           
            return "";
        }

        private void button1_Click(object sender, EventArgs e)
        {

            WebReference.LisBaseService service = new LisBaseService();
            service.Timeout = -1;
            object obj = service.getPatientinfo("045087195");
            textBox1.Text = obj.ToString();
        }
    }
}

  • 写回答

20条回答 默认 最新

  • Code_流苏 C/C++领域优质创作者 2022-02-04 22:52
    关注
    获得4.50元问题酬金

    504 (网关超时) 服务器作为网关或代理,但是没有及时从上游服务器收到请求。超时了没收到请求。
    这个问题估计是由后端电脑之间 IP 通讯缓慢而产生,可能包括您的 Web 服务器。如果您的 Web 服务器由某网站托管,需要找相关人员解决。一般来说,是由于被请求服务器发送超时引起。

    评论

报告相同问题?

问题事件

  • 系统已结题 2月5日
  • 修改了问题 1月28日
  • 赞助了问题酬金50元 1月28日
  • 赞助了问题酬金50元 1月28日
  • 展开全部

悬赏问题

  • ¥15 esp32驱动GC9A01循环播放视频
  • ¥15 惠普360g9的最新bios
  • ¥15 配置hadoop时start-all.sh老是启动失败
  • ¥30 这个功能用什么软件发合适?
  • ¥60 微信小程序,取消订单,偶尔订单没有改变状态
  • ¥15 用pytorch实现PPO算法
  • ¥15 关于调制信号的星座图?
  • ¥30 前端传参时,后端接收不到参数
  • ¥15 这是有什么问题吗,我检查许可证了但是显示有呢
  • ¥15 机器学习预测遇到的目标函数问题