Web services 如何在webservice引用上设置HTTP请求头?

Web services 如何在webservice引用上设置HTTP请求头?,web-services,http-headers,Web Services,Http Headers,问题是 Dim OrderService As getOrderData.GetOrderDataInterfaceClient = New getOrderData.GetOrderDataInterfaceClient()   Dim returnedXML = OrderService.orderInfo("OrderNumber") and be authorized by the JBoss server and get back return data. 我有一个Web服务,它

问题是

  Dim OrderService As getOrderData.GetOrderDataInterfaceClient = New getOrderData.GetOrderDataInterfaceClient()
  Dim returnedXML = OrderService.orderInfo("OrderNumber") and be authorized by the JBoss server and get back return data.
我有一个Web服务,它可以很好地处理JAVA代码

package com.mypackage.myproject;

 public class ExecuteGetOrder {


public static void main(String [ ] args)
{
     try {



        runGetOrder();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}




public static void runGetOrder() throws Exception
 {

        GetOrderDataInterface data = new GetOrderDataInterfaceProxy().getGetOrderDataInterface();
        ((org.apache.axis.client.Stub)data)._setProperty(org.apache.axis.client.Call.USERNAME_PROPERTY, "ent=,user=UserName");
        ((org.apache.axis.client.Stub)data)._setProperty(org.apache.axis.client.Call.PASSWORD_PROPERTY, "password");
        String RtrnDataXML = data.OrderInfo("OrderNumber");
        System.out.println(RtrnDataXML);




}



}
  Dim OrderService As getOrderData.GetOrderDataInterfaceClient = New getOrderData.GetOrderDataInterfaceClient()
  Dim returnedXML = OrderService.orderInfo("OrderNumber") and be authorized by the JBoss server and get back return data.
原始请求如下所示

POST http://win-bpqhaq6l0jt:8008/oms/services/GetOrderData HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Host: win-bpqhaq6l0jt:8008
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 366
Authorization: Basic ZW50PSx1c2VyPUEyTENNQWRtaW46cGFzc3dvcmQ=

<?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><ammoOrderInfo xmlns="http://a2lcm.rhinotechnology.com/"><order xmlns="">OrderNumber</order></OrderInfo></soapenv:Body></soapenv:Envelope>
  Dim OrderService As getOrderData.GetOrderDataInterfaceClient = New getOrderData.GetOrderDataInterfaceClient()
  Dim returnedXML = OrderService.orderInfo("OrderNumber") and be authorized by the JBoss server and get back return data.
我得到这个

HTTP/1.1 401 Unauthorized
Server: Apache-Coyote/1.1
WWW-Authenticate: Basic host=10.20.100.7
Content-Type: text/html;charset=utf-8
Content-Length: 948
Date: Fri, 30 May 2014 21:25:05 GMT

<html><head><title>JBossWeb/2.0.1.GA - Error report</title><style><!--H1 {font- family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-  family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 401 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p>  <b>description</b> <u>This request requires HTTP authentication ().</u></p><HR size="1" noshade="noshade"><h3>JBossWeb/2.0.1.GA</h3></body></html>
  Dim OrderService As getOrderData.GetOrderDataInterfaceClient = New getOrderData.GetOrderDataInterfaceClient()
  Dim returnedXML = OrderService.orderInfo("OrderNumber") and be authorized by the JBoss server and get back return data.

因此,对于所有尝试使用JBoss web服务进行基本身份验证的人来说,解决方案都是

  Dim OrderService As getOrderData.GetOrderDataInterfaceClient = New getOrderData.GetOrderDataInterfaceClient()
  Dim returnedXML = OrderService.orderInfo("OrderNumber") and be authorized by the JBoss server and get back return data.
1) 添加以下类(vb中的代码)

  Dim OrderService As getOrderData.GetOrderDataInterfaceClient = New getOrderData.GetOrderDataInterfaceClient()
  Dim returnedXML = OrderService.orderInfo("OrderNumber") and be authorized by the JBoss server and get back return data.

您刚才添加到问题中的解决方案应该是答案。你可以回答你自己的问题,甚至接受你的答案。