求助怎么通过WEBSERVICE的身份验证,JAVA那边提供了一个用户名和密码,我每次调用WEBSERVICE的接口都提示我必须通过身份验证才能操作,但是他们那边又没有专门提供登陆方法给我登陆,这该肿么做?是不是在实例化接口的时候可以做登陆操作呢?

解决方案 »

  1.   

    给出 SERVICE 地址 或 WSDL 
      

  2.   

    SERVICE 地址:http://yiwuht.chachaba.com:8082/service/stallService?wsdl
      

  3.   

     WSDL <?xml version="1.0" encoding="UTF-8"?>
    -<wsdl:definitions xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://service.map.chachaba" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:ns1="http://entity.map.chachaba" targetNamespace="http://service.map.chachaba"> -<wsdl:types> -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://entity.map.chachaba" elementFormDefault="qualified" attributeFormDefault="qualified"> -<xsd:complexType name="Stalls"> -<xsd:sequence> <xsd:element name="address" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="business" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="contact" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="description" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="floor" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="hygieneNumber" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="id" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="img" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="infourl" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="licenseNumber" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="management" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="name" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="phoneNumber" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="qqnumber" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="recommend" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="scale" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="sid" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="square" type="xsd:int" nillable="true" minOccurs="0"/> <xsd:element name="taxNumber" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="webAdd" type="xsd:string" nillable="true" minOccurs="0"/> <xsd:element name="workHour" type="xsd:string" nillable="true" minOccurs="0"/> </xsd:sequence> </xsd:complexType> </xsd:schema> -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://service.map.chachaba" elementFormDefault="qualified" attributeFormDefault="qualified"> -<xsd:element name="saveInter"> -<xsd:complexType> -<xsd:sequence> <xsd:element name="in0" type="ns1:Stalls" nillable="true" minOccurs="1" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element> -<xsd:element name="saveInterResponse"> <xsd:complexType/> </xsd:element> -<xsd:element name="deleteInter"> -<xsd:complexType> -<xsd:sequence> <xsd:element name="in0" type="xsd:string" nillable="true" minOccurs="1" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element> -<xsd:element name="deleteInterResponse"> <xsd:complexType/> </xsd:element> -<xsd:element name="updateInter"> -<xsd:complexType> -<xsd:sequence> <xsd:element name="in0" type="ns1:Stalls" nillable="true" minOccurs="1" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element> -<xsd:element name="updateInterResponse"> <xsd:complexType/> </xsd:element> </xsd:schema> </wsdl:types> -<wsdl:message name="deleteInterResponse"> <wsdl:part name="parameters" element="tns:deleteInterResponse"> </wsdl:part> </wsdl:message> -<wsdl:message name="saveInterResponse"> <wsdl:part name="parameters" element="tns:saveInterResponse"> </wsdl:part> </wsdl:message> -<wsdl:message name="saveInterRequest"> <wsdl:part name="parameters" element="tns:saveInter"> </wsdl:part> </wsdl:message> -<wsdl:message name="updateInterResponse"> <wsdl:part name="parameters" element="tns:updateInterResponse"> </wsdl:part> </wsdl:message> -<wsdl:message name="updateInterRequest"> <wsdl:part name="parameters" element="tns:updateInter"> </wsdl:part> </wsdl:message> -<wsdl:message name="deleteInterRequest"> <wsdl:part name="parameters" element="tns:deleteInter"> </wsdl:part> </wsdl:message> -<wsdl:portType name="StallsServicePortType"> -<wsdl:operation name="saveInter"> <wsdl:input name="saveInterRequest" message="tns:saveInterRequest"> </wsdl:input> <wsdl:output name="saveInterResponse" message="tns:saveInterResponse"> </wsdl:output> </wsdl:operation> -<wsdl:operation name="deleteInter"> <wsdl:input name="deleteInterRequest" message="tns:deleteInterRequest"> </wsdl:input> <wsdl:output name="deleteInterResponse" message="tns:deleteInterResponse"> </wsdl:output> </wsdl:operation> -<wsdl:operation name="updateInter"> <wsdl:input name="updateInterRequest" message="tns:updateInterRequest"> </wsdl:input> <wsdl:output name="updateInterResponse" message="tns:updateInterResponse"> </wsdl:output> </wsdl:operation> </wsdl:portType> -<wsdl:binding name="StallsServiceHttpBinding" type="tns:StallsServicePortType"> <wsdlsoap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> -<wsdl:operation name="saveInter"> <wsdlsoap:operation soapAction=""/> -<wsdl:input name="saveInterRequest"> <wsdlsoap:body use="literal"/> </wsdl:input> -<wsdl:output name="saveInterResponse"> <wsdlsoap:body use="literal"/> </wsdl:output> </wsdl:operation> -<wsdl:operation name="deleteInter"> <wsdlsoap:operation soapAction=""/> -<wsdl:input name="deleteInterRequest"> <wsdlsoap:body use="literal"/> </wsdl:input> -<wsdl:output name="deleteInterResponse"> <wsdlsoap:body use="literal"/> </wsdl:output> </wsdl:operation> -<wsdl:operation name="updateInter"> <wsdlsoap:operation soapAction=""/> -<wsdl:input name="updateInterRequest"> <wsdlsoap:body use="literal"/> </wsdl:input> -<wsdl:output name="updateInterResponse"> <wsdlsoap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> -<wsdl:service name="StallsService"> -<wsdl:port name="StallsServiceHttpPort" binding="tns:StallsServiceHttpBinding"> <wsdlsoap:address location="http://yiwuht.chachaba.com:8082/service/stallService"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
      

  4.   

    或者打开这个连接:http://0001688.com/stallService.xml
      

  5.   

    本帖最后由 xuzuning 于 2012-11-19 10:47:47 编辑
      

  6.   

    那这个是不是需要JAVA那边做一些改动呢?我现在不知道怎么处理这个问题求解决方案啊
      

  7.   

    本帖最后由 xuzuning 于 2012-11-19 11:28:03 编辑
      

  8.   

    对方有给你账号密码吗?
    我只做过webservice的demo 还没试过实际应用
    lz能不能把错误提示信息贴出来 看下是那种身份验证。我只做过头部信息验证 $client = new SoapClient('hello.wsdl');
        //链接服务器端 先做一个身份验证
        $h = new SoapHeader('mynamespace', 'checkUser', 'xiebuqing');
        $client->__setSoapHeaders($h);
      

  9.   

    http://0001688.com/stallService.xml这个是外网可以访问的
    调用代码: $client = new SoapClient('http://yiwuht.chachaba.com:8082/service/stallService?wsdl');
    //$client1 = new SoapHeader('addOutHandler', );
    echo ("WebService提供的开放函数:");
    echo ('<pre>');
    print_r ( $client->__getFunctions () );
    echo ('</pre>');
    echo ("WebService提供的Type:");
    echo ('<pre>');
    print_r ( $client->__getTypes () );
    echo ('</pre>');
    echo ("执行GetGUIDNode的结果:");
    var_dump($client->saveInter()) ;错误信息请看下图
      

  10.   

    这个webservice是哪里提供的? 我看他的函数名像是个demo  你如果联系得上提供者,你找他拿验证信息(应该会有有个账号密码的吧!)
    给你看下如果提供者要求头部信息验证,请求者没经过验证报的错误。自己的demo
      

  11.   

    用户名跟密码是有的,就是不知道怎么发送验证信息,所以调用不了非公开的方法,像我们PHP接受用户信息都是有一个指定的表单名,比如username,password,然后我们PHP用POST或者GET接受参数,我不知道JAVA那边是怎么验证我们的,所以我不知道怎么把用户名和密码传递给JAVA验证身份
      

  12.   

    你能和供应方联系吗,他们写java的  给不了你php的验证方式,应该给得了java的验证方式吧? 你拿到java的验证方式后,看下他到底是用什么验证方式,再去找php相应的验证方式吧。如果是用soapheader验证方式。java php都有相应的类/函数 
    “我不知道JAVA那边是怎么验证我们的,所以我不知道怎么把用户名和密码传递给JAVA验证身份”
    webservice验证方式应该不止一种,这个问题只有供应商能回答你,你可以尝试一下是不是头部验证
    $client = new SoapHeader('addOutHandler','checkUser','xiebuqing');
    参数 : 1命名空间(这个可以由你自己定)  2账号(其实是他的方法) 3密码/验证码