简体   繁体   English

具有wsimport的Java Web Service客户端未连接到主机

[英]Java Web Service Client With wsimport Not Connecting To Host

I'm working on a custom authentication provider for Cognos. 我正在为Cognos开发自定义身份验证提供程序。 We have a webservice that will be listening for auth requests. 我们有一个Web服务,它将监听身份验证请求。 For testing purposes I'm just trying to send a user/pass (will be changed later to use session information). 出于测试目的,我只是尝试发送用户/密码(稍后将更改为使用会话信息)。

I've been trying to get a POC working in a simple Java console app before implementing the custom provider. 在实现自定义提供程序之前,我一直试图让POC在简单的Java控制台应用程序中工作。 I am having trouble getting the client to communicate with the web service. 我无法让客户端与Web服务进行通信。 I used the wsimport to generate my classes using the keep flag. 我使用wsimport使用keep标志生成类。 I brought the generated java files into my Eclipse project and built a main method like so: 我将生成的java文件带到我的Eclipse项目中,并构建了如下的主要方法:

CognosAuthentication service = new CognosAuthentication();

CognosAuthenticationSoap soapClient = service.getCognosAuthenticationSoap();

CognosUser user = soapClient.validateDevSession("username", "password");

System.out.println(user == null ? "User was null" : user.getUserName());

I've tried also specifying the URL for the service (both with '?wsdl' appended on the end and not): 我也尝试过指定服务的URL(都在末尾加上“?wsdl”):

CognosAuthentication service = new CognosAuthentication(new URL("http://somehost/CognosAuthentication.asmx"), new QName("http://tempuri.org/", "CognosAuthentication"));

Where is the WSDL that is generated by the service: 服务生成的WSDL在哪里:

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s1="http://www.ourcompany.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
      <s:import namespace="http://www.ourcompany.com/" />
      <s:element name="ValidateSession">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="username" type="s:string" />
            <s:element minOccurs="0" maxOccurs="1" name="expires" type="s:string" />
            <s:element minOccurs="0" maxOccurs="1" name="userId" type="s:string" />
            <s:element minOccurs="0" maxOccurs="1" name="authToken" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="ValidateSessionResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="1" ref="s1:ValidateSessionResult" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="ValidateDevSession">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="username" type="s:string" />
            <s:element minOccurs="0" maxOccurs="1" name="password" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="ValidateDevSessionResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="1" ref="s1:ValidateDevSessionResult" />
          </s:sequence>
        </s:complexType>
      </s:element>
    </s:schema>
    <s:schema elementFormDefault="qualified" targetNamespace="http://www.ourcompany.com/">
      <s:element name="ValidateSessionResult" nillable="true" type="s1:CognosUser" />
      <s:complexType name="CognosUser">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="CognosSlot" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="GroupName" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="UserName" type="s:string" />
        </s:sequence>
      </s:complexType>
      <s:element name="ValidateDevSessionResult" nillable="true" type="s1:CognosUser" />
    </s:schema>
  </wsdl:types>
  <wsdl:message name="ValidateSessionSoapIn">
    <wsdl:part name="parameters" element="tns:ValidateSession" />
  </wsdl:message>
  <wsdl:message name="ValidateSessionSoapOut">
    <wsdl:part name="parameters" element="tns:ValidateSessionResponse" />
  </wsdl:message>
  <wsdl:message name="ValidateDevSessionSoapIn">
    <wsdl:part name="parameters" element="tns:ValidateDevSession" />
  </wsdl:message>
  <wsdl:message name="ValidateDevSessionSoapOut">
    <wsdl:part name="parameters" element="tns:ValidateDevSessionResponse" />
  </wsdl:message>
  <wsdl:portType name="CognosAuthenticationSoap">
    <wsdl:operation name="ValidateSession">
      <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Gets user information based on the authentication token</wsdl:documentation>
      <wsdl:input message="tns:ValidateSessionSoapIn" />
      <wsdl:output message="tns:ValidateSessionSoapOut" />
    </wsdl:operation>
    <wsdl:operation name="ValidateDevSession">
      <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Gets user information based on the authentication token</wsdl:documentation>
      <wsdl:input message="tns:ValidateDevSessionSoapIn" />
      <wsdl:output message="tns:ValidateDevSessionSoapOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="CognosAuthenticationSoap" type="tns:CognosAuthenticationSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="ValidateSession">
      <soap:operation soapAction="http://tempuri.org/ValidateSession" style="document" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="ValidateDevSession">
      <soap:operation soapAction="http://tempuri.org/ValidDevSession" style="document" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="CognosAuthenticationSoap12" type="tns:CognosAuthenticationSoap">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="ValidateSession">
      <soap12:operation soapAction="http://tempuri.org/ValidateSession" style="document" />
      <wsdl:input>
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="ValidateDevSession">
      <soap12:operation soapAction="http://tempuri.org/ValidDevSession" style="document" />
      <wsdl:input>
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="CognosAuthentication">
    <wsdl:port name="CognosAuthenticationSoap" binding="tns:CognosAuthenticationSoap">
      <soap:address location="http://mbeard2/LMS/app/analytics/CognosAuthentication.asmx" />
    </wsdl:port>
    <wsdl:port name="CognosAuthenticationSoap12" binding="tns:CognosAuthenticationSoap12">
      <soap12:address location="http://mbeard2/LMS/app/analytics/CognosAuthentication.asmx" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

I assume that I've done all the correct steps using wsimport. 我假设我已经使用wsimport完成了所有正确的步骤。 The issue that I am facing is that it never does anything. 我面临的问题是它永远不会任何事情。 I can fire up fiddler and watch that no network traffic occurs. 我可以启动提琴手,观察没有网络流量发生。 The user object always is null. 用户对象始终为null。 Is there something that I need to configure? 我需要配置一些东西吗? Is there something odd about the webservice being a C#/ASP.NET service? Web服务是C#/ ASP.NET服务是否有些奇怪? Am I missing something in how I'm using the SOAP request structure? 我在使用SOAP请求结构时是否缺少某些东西?

I'm not getting any errors during compilation nor when I run the code. 在编译期间或运行代码时都没有出现任何错误。 I'm scratching my head for answers! 我正在努力寻找答案!

SO needs a "Close My Question Because I'm A Dunce" option. 因此,需要“关闭我的问题,因为我是一个笨蛋”选项。 Somehow fiddler was not picking up on the request. 不知何故,提琴手没有接听请求。 I got a remote debug hooked up to the webservice and saw the request come in and get kicked out because I mistyped the password. 我进行了远程调试,连接到了Web服务,并看到请求输入并被踢出,因为我输错了密码。 Oh well... 那好吧...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM