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

通过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条回答 默认 最新

相关推荐 更多相似问题