从 Domino 使用 Web 服务时出现错误 401

Error 401 when consuming web service from Domino

编辑: 似乎 Domino 没有随 Soap 请求一起发送安全性 header。我可以访问服务提供商的日志,这是我发现的内容:

2016-06-09 10:27:01 EDT [MED.0050.0239D] Substituted fault reason = Mediator encountered an error:Incoming request does not contain the Authorization header. This service requires the HTTP Basic Authentication token to be present! while executing operation:retraitEquipementServMoCA service:equipementMoCA at time:10:27:01 on date:2016-06-09. The client ip was:10.150.1.34. The current user:Default. The consumer application:null 

所以我要将安全性 header 添加到存根中???

我必须修改使用 Web 服务的现有 Lotus Notes 应用程序。在产品中一切正常,但在开发中,我们有一个新的 WSDL,端点也是一个开发服务器。

我必须修改定义定位器、存根和服务的行以适应新的 WSDL(端口名称已更改),我认为我做对了。

我不明白这是怎么回事。我读到 Domino 仅支持 SOAP 1.1,因此我修改了 WSDL 以使用 soap 1.1 而不是 1.2,但我仍然遇到 401 错误。

我现在已经在 Domino 中从 WSDL 重建 Web 消费者大约 3-4 次,但我无法停止收到 401 错误。这是日志的一部分:

2016-06-09 08:26:25   HTTP JVM: DEBUG endpoint: http://bsiesglba1.int.videotron.com:5555/ws/equipementMoCA
2016-06-09 08:26:25   HTTP JVM: DEBUG portname: equipementMoCA.equipementMoCAsoaphttp
2016-06-09 08:26:25   HTTP JVM: ==DEBUG==
2016-06-09 08:26:25   HTTP JVM: URL: http://bsiesglba1.int.videotron.com:5555/ws/equipementMoCA
2016-06-09 08:26:25   HTTP JVM: User:  : 
2016-06-09 08:26:25   HTTP JVM: Erreur MoCa : Agent MoCaRequest
2016-06-09 08:26:25   HTTP JVM: WebServiceEngineFault
2016-06-09 08:26:25   HTTP JVM:  faultCode: {http://www.lotus.com/domino/ws/}HTTP
2016-06-09 08:26:25   HTTP JVM:  faultSubcode: 
2016-06-09 08:26:25   HTTP JVM:  faultString: (401) 401
2016-06-09 08:26:25   HTTP JVM:  faultActor: 
2016-06-09 08:26:25   HTTP JVM:  faultNode: 
2016-06-09 08:26:25   HTTP JVM:  faultDetail: 
2016-06-09 08:26:25   HTTP JVM:     {}string: 
2016-06-09 08:26:25   HTTP JVM: (401) 401
2016-06-09 08:26:25   HTTP JVM:     at lotus.domino.axis.transport.http.HTTPSender.readFromSocket(Unknown Source)
2016-06-09 08:26:25   HTTP JVM:     at lotus.domino.axis.transport.http.HTTPSender.invoke(Unknown Source)
2016-06-09 08:26:25   HTTP JVM:     at lotus.domino.axis.strategies.InvocationStrategy.visit(Unknown Source)
2016-06-09 08:26:25   HTTP JVM:     at lotus.domino.axis.SimpleChain.doVisiting(Unknown Source)
2016-06-09 08:26:25   HTTP JVM:     at lotus.domino.axis.SimpleChain.invoke(Unknown Source)
2016-06-09 08:26:25   HTTP JVM:     at lotus.domino.axis.client.AxisClient.invoke(Unknown Source)
2016-06-09 08:26:25   HTTP JVM:     at lotus.domino.axis.client.Call.invokeEngine(Unknown Source)
2016-06-09 08:26:25   HTTP JVM:     at lotus.domino.axis.client.Call.invoke(Unknown Source)
2016-06-09 08:26:25   HTTP JVM:     at lotus.domino.axis.client.Call.invoke(Unknown Source)
2016-06-09 08:26:25   HTTP JVM:     at lotus.domino.axis.client.Call.invoke(Unknown Source)
2016-06-09 08:26:25   HTTP JVM:     at lotus.domino.axis.client.Call.invoke(Unknown Source)
2016-06-09 08:26:25   HTTP JVM:     at lotus.domino.websvc.client.Call.invoke(Unknown Source)
2016-06-09 08:26:25   HTTP JVM:     at com.videotron.www.MoCA.gestionEquipement.ServiceConfActMngt_HomeNetworking_webservices_equipementMoCA_BinderStub.retraitEquipementServMoCA(ServiceConfActMngt_HomeNetworking_webservices_equipementMoCA_BinderStub.java:20)
2016-06-09 08:26:25   HTTP JVM:     at com.videotron.factory.equipementMoCaFactory.WSClientFactory.wsRemoveEquipment(Unknown Source)
2016-06-09 08:26:25   HTTP JVM:     at MoCaRequest.NotesMain(Unknown Source)
2016-06-09 08:26:25   HTTP JVM:     at lotus.domino.AgentBase.runNotes(Unknown Source)
2016-06-09 08:26:25   HTTP JVM:     at lotus.domino.NotesThread.run(Unknown Source)

这是 WSDL:

<wsdl:definitions name="equipementMoCA" targetNamespace="http://www.videotron.com/MoCA/gestionEquipement" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:tns="http://www.videotron.com/MoCA/gestionEquipement" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/">
<wsdl:documentation/>
  <wsdl:types>
    <xsd:schema targetNamespace="http://www.videotron.com/MoCA/gestionEquipement">
            <xsd:complexType name="retraitEquipementServMoCA">
              <xsd:sequence>
                <xsd:element name="noCompteClient" nillable="true" type="xsd:string"/>
                <xsd:element name="noSerie" nillable="true" type="xsd:string"/>
                <xsd:element name="typeAppareil" nillable="true" type="xsd:string"/>
                <xsd:element name="systemeSource" nillable="true" type="xsd:string"/>
              </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="cErrorDefRec">
              <xsd:sequence>
                <xsd:element name="errorNb" nillable="true" type="xsd:string"/>
                <xsd:element name="errorText" nillable="true" type="xsd:string"/>
                <xsd:element name="severity" nillable="true" type="xsd:string"/>
                <xsd:element name="errorType" nillable="true" type="xsd:string"/>
              </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="ajoutEquipementServMoCA">
              <xsd:sequence>
                <xsd:element name="noCompteClient" nillable="true" type="xsd:string"/>
                <xsd:element name="noSerie" nillable="true" type="xsd:string"/>
                <xsd:element name="typeAppareil" nillable="true" type="xsd:string"/>
                <xsd:element name="systemeSource" nillable="true" type="xsd:string"/>
              </xsd:sequence>
            </xsd:complexType>
            <xsd:element name="ajoutEquipementServMoCA" type="tns:ajoutEquipementServMoCA"/>
            <xsd:element name="cErrorDefRec" type="tns:cErrorDefRec"/>
            <xsd:element name="retraitEquipementServMoCA" type="tns:retraitEquipementServMoCA"/>
          </xsd:schema>
  </wsdl:types>
  <wsdl:message name="equipementMoCA_PortType_retraitEquipementServMoCA">
    <wsdl:part name="parameters" element="tns:retraitEquipementServMoCA">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="equipementMoCA_PortType_ajoutEquipementServMoCA">
    <wsdl:part name="parameters" element="tns:ajoutEquipementServMoCA">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="equipementMoCA_PortType_cErrorDefRec">
    <wsdl:part name="parameters" element="tns:cErrorDefRec">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="equipementMoCA_PortType">
    <wsdl:operation name="ajoutEquipementServMoCA">
      <wsdl:input message="tns:equipementMoCA_PortType_ajoutEquipementServMoCA">
    </wsdl:input>
      <wsdl:output message="tns:equipementMoCA_PortType_cErrorDefRec">
    </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="retraitEquipementServMoCA">
      <wsdl:input message="tns:equipementMoCA_PortType_retraitEquipementServMoCA">
    </wsdl:input>
      <wsdl:output message="tns:equipementMoCA_PortType_cErrorDefRec">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="ServiceConfActMngt_HomeNetworking_webservices_equipementMoCA_Binder" type="tns:equipementMoCA_PortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="ajoutEquipementServMoCA">
      <soap:operation soapAction="ServiceConfActMngt_HomeNetworking_webservices_equipementMoCA_Binder_ajoutEquipementServMoCA" style="document"/>
      <wsdl:input>
        <soap:body parts="parameters" use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body parts="parameters" use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="retraitEquipementServMoCA">
      <soap:operation soapAction="ServiceConfActMngt_HomeNetworking_webservices_equipementMoCA_Binder_retraitEquipementServMoCA" style="document"/>
      <wsdl:input>
        <soap:body parts="parameters" use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body parts="parameters" use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="equipementMoCA">
    <wsdl:port name="equipementMoCAsoaphttp" binding="tns:ServiceConfActMngt_HomeNetworking_webservices_equipementMoCA_Binder">
      <soap:address location="http://bsiesglba1.int.videotron.com:5555/ws/equipementMoCA"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

最后,wsFactory 的代码 class:

public class WSClientFactory {

    private String endPoint;
    private String userName;
    private String password;
    private int timeOutDelayInMilliSec =60000; //default

    // ****** propriétées input du ws ********
    private String noCompteClient= new String(""); 
    private String noSerie= new String(""); 
    private String typeAppareil= new String(""); 
    private String systemeSource= new String(""); 
    // ****** propriétées output du ws ********
    private StringHolder errorNb= new StringHolder(""); 
    private StringHolder errorText= new StringHolder(""); 
    private StringHolder severity= new StringHolder(""); 
    private StringHolder errorType= new StringHolder(""); 

    // ****** propriétés locales
    EquipementMoCALocator locator;
    ServiceConfActMngt_HomeNetworking_webservices_equipementMoCA_BinderStub stub;
    EquipementMoCA_PortType service;

    public WSClientFactory(String endPoint, String userName, String password, int timeOutDelayInMilliSec ) throws ServiceException, MalformedURLException {
        this.endPoint = endPoint;
        this.userName = userName;
        this.password = password;
        this.timeOutDelayInMilliSec = timeOutDelayInMilliSec;

        // The Locator class knows how to access our web service 
        //ServiceActivationMoCALocator locator = new ServiceActivationMoCALocator();
        locator = new EquipementMoCALocator();
        //stub = (ServiceConfActMngt_HomeNetworking_webservices_equipementMoCA_BinderStub) locator.getServiceConfActMngt_HomeNetworking_webservices_equipementMoCA_Port(new URL(endPoint));
        //service = locator.getServiceConfActMngt_HomeNetworking_webservices_equipementMoCA_Port();
        stub = (ServiceConfActMngt_HomeNetworking_webservices_equipementMoCA_BinderStub) locator.getEquipementMoCAsoaphttp(new URL(endPoint));
        service = locator.getEquipementMoCAsoaphttp();

        System.out.print("DEBUG endpoint: " + stub.getEndpoint());
        System.out.print("DEBUG portname: " + stub.getPortName());

        // setting du timeout pour la durée maxi avant output du ws
        stub.setTimeout(timeOutDelayInMilliSec);

        // Authentication
        if (!userName.equals("")){
            stub._setProperty(lotus.domino.axis.client.Call.USERNAME_PROPERTY, userName);
            stub._setProperty(lotus.domino.axis.client.Call.PASSWORD_PROPERTY, password);
        }
    }
    public WSClientFactory(String endPoint, String userName, String password)throws ServiceException, MalformedURLException  {
        this.endPoint = endPoint;
        this.userName = userName;
        this.password = password;

        // The Locator class knows how to access our web service 
        //ServiceActivationMoCALocator locator = new ServiceActivationMoCALocator();
        locator = new EquipementMoCALocator();
        //stub = (ServiceConfActMngt_HomeNetworking_webservices_equipementMoCA_BinderStub) locator.getServiceConfActMngt_HomeNetworking_webservices_equipementMoCA_Port(new URL(endPoint));
        //service = locator.getServiceConfActMngt_HomeNetworking_webservices_equipementMoCA_Port();
        stub = (ServiceConfActMngt_HomeNetworking_webservices_equipementMoCA_BinderStub) locator.getEquipementMoCAsoaphttp(new URL(endPoint));
        service = locator.getEquipementMoCAsoaphttp();

        // setting du timeout pour la durée maxi avant output du ws
        stub.setTimeout(timeOutDelayInMilliSec);

        // Authentication
        if (!userName.equals("")){
            stub._setProperty(lotus.domino.axis.client.Call.USERNAME_PROPERTY, userName);
            stub._setProperty(lotus.domino.axis.client.Call.PASSWORD_PROPERTY, password);
        }
    }
    /*
     * Methode permettant de faire l'ajout d'un appareil (noSerie) au comtpe client(noCompteClient) dans le dépôt MoCa
     */
    public boolean wsAddEquipment(String noCompteClient,  String noSerie,  String typeAppareil,  String systemeSource) throws MalformedURLException, ServiceException, RemoteException{

        service.ajoutEquipementServMoCA(noCompteClient,  noSerie,  typeAppareil,  systemeSource,  
                this.errorNb,  this.errorText,  this.severity,  this.errorType);

        // dans la réponse du ws, si la valeur de erroNb = 0, c'est que ça a fonctionné
        if (this.errorNb.equals("0")){
            return true;
        }else {
            return false;
        }

    }

    /*
     * Methode permettant de faire la suppression d'un appareil (noSerie) au comtpe client(noCompteClient) dans le dépôt MoCa
     */
    public boolean wsRemoveEquipment(String noCompteClient,  String noSerie,  String typeAppareil,  String systemeSource) throws MalformedURLException, ServiceException, RemoteException{

        service.retraitEquipementServMoCA(noCompteClient,  noSerie,  typeAppareil,  systemeSource,  
                this.errorNb,  this.errorText,  this.severity,  this.errorType);

        // dans la réponse du ws, si la valeur de erroNb = 0, c'est que ça a fonctionné
        if (this.errorNb.equals("0")){
            return true;
        }else {
            return false;
        }
    }

和存根 class:

package com.videotron.www.MoCA.gestionEquipement;

public class ServiceConfActMngt_HomeNetworking_webservices_equipementMoCA_BinderStub extends lotus.domino.websvc.client.Stub implements com.videotron.www.MoCA.gestionEquipement.EquipementMoCA_PortType {

    public ServiceConfActMngt_HomeNetworking_webservices_equipementMoCA_BinderStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws lotus.domino.types.Fault {
         super(endpointURL, service);
    }

    public void ajoutEquipementServMoCA(java.lang.String noCompteClient, java.lang.String noSerie, java.lang.String typeAppareil, java.lang.String systemeSource, javax.xml.rpc.holders.StringHolder errorNb, javax.xml.rpc.holders.StringHolder errorText, javax.xml.rpc.holders.StringHolder severity, javax.xml.rpc.holders.StringHolder errorType) throws java.rmi.RemoteException {
        lotus.domino.websvc.client.Call _call = createCall("ajoutEquipementServMoCA");
        java.lang.Object _resp = _call.invoke(new java.lang.Object[] {noCompteClient, noSerie, typeAppareil, systemeSource});
        errorNb.value = (java.lang.String) _call.convertOutputParam("", "errorNb", java.lang.String.class);
        errorText.value = (java.lang.String) _call.convertOutputParam("", "errorText", java.lang.String.class);
        severity.value = (java.lang.String) _call.convertOutputParam("", "severity", java.lang.String.class);
        errorType.value = (java.lang.String) _call.convertOutputParam("", "errorType", java.lang.String.class);
    }

    public void retraitEquipementServMoCA(java.lang.String noCompteClient, java.lang.String noSerie, java.lang.String typeAppareil, java.lang.String systemeSource, javax.xml.rpc.holders.StringHolder errorNb, javax.xml.rpc.holders.StringHolder errorText, javax.xml.rpc.holders.StringHolder severity, javax.xml.rpc.holders.StringHolder errorType) throws java.rmi.RemoteException {
        lotus.domino.websvc.client.Call _call = createCall("retraitEquipementServMoCA");
        java.lang.Object _resp = _call.invoke(new java.lang.Object[] {noCompteClient, noSerie, typeAppareil, systemeSource});
        errorNb.value = (java.lang.String) _call.convertOutputParam("", "errorNb", java.lang.String.class);
        errorText.value = (java.lang.String) _call.convertOutputParam("", "errorText", java.lang.String.class);
        severity.value = (java.lang.String) _call.convertOutputParam("", "severity", java.lang.String.class);
        errorType.value = (java.lang.String) _call.convertOutputParam("", "errorType", java.lang.String.class);
    }

}

我不知道你是否需要更多信息,但如果需要我会添加它们。

我已经使用 SoapUI 成功连接到 Web 服务,所以我知道它可以在提供商端运行。

代码是运行Domino Release 9.0.1FP4 HF525

好吧,我设法找到了解决方案,而且就在我眼皮底下...

如果您查看 "JMP 105 – XML and Web Services Jumpstart" 幻灯片(可在此处找到:http://www.nnsu.com/nnsusite.nsf/xsp/.ibmmodres/domino/OpenAttachment/nnsusite.nsf/6343B286B9778CE6862576B60062BB1F/Content/JMP105.pdf),其中有几张幻灯片告诉您在何处添加凭据。没什么特别的,您只需将它们添加到 Designer 从您要使用的 Web 服务的 WSDL 文件生成的存根代码中。它在 LotusScript 的第 114 页和 Java.

的第 120 页

这解决了我的问题!!!