Topic
  • No replies
PangSMS
PangSMS
21 Posts

Pinned topic How to call web service (wsdl)

‏2014-07-19T18:49:12Z |

Dear.

I used HATS 8.5 to create web service check AS400 signon.

first of all, i'll explain what i done.

I create macro Signon.hma
S1 - prompt username and password  --> start macro signon screen
S2 - extract menu --> stop macro main menu
S3 - extract error --> stop macro login fail

then i generate integration object --->  create web service as WSDL

Next...

I open new web project --> import Signon.wsdl --> create webservice client

Test web service by Test web service by Explorer. it's work.

Here my signon.wsdl

<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://webserviceclasses" xmlns:impl="http://webserviceclasses" xmlns:intf="http://webserviceclasses" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsi="http://ws-i.org/profiles/basic/1.1/xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <wsdl:types>
  <schema xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://webserviceclasses">
   <element name="getNestedBeanNamesResponse">
    <complexType>
     <sequence>
      <element name="getNestedBeanNamesReturn" nillable="true" type="impl:ArrayOf_67326035_1440052060_nillable_string"/>
     </sequence>
    </complexType>
   </element>
   <element name="signOnProcessWS">
    <complexType>
     <sequence>
      <element name="inputFromClient" nillable="true" type="impl:Signon_SignOn_Input_Properties"/>
     </sequence>
    </complexType>
   </element>
   <element name="signOnProcessWSResponse">
    <complexType>
     <sequence>
      <element name="signOnProcessWSReturn" nillable="true" type="impl:Signon_SignOn_Output_Properties"/>
     </sequence>
    </complexType>
   </element>
   <element name="getNestedBeanNames">
    <complexType>
     <sequence/>
    </complexType>
   </element>
   <complexType name="ArrayOf_67326035_1440052060_nillable_string">
    <sequence>
     <element maxOccurs="unbounded" minOccurs="0" name="string" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>
   <complexType name="Signon_SignOn_Input_Properties">
    <sequence>
     <element name="password" nillable="true" type="xsd:string"/>
     <element name="username" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>
   <complexType name="Signon_SignOn_Output_Properties">
    <sequence>
     <element name="emsg" nillable="true" type="xsd:string"/>
     <element name="output" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>
  </schema>
 </wsdl:types>
 
   <wsdl:message name="signOnProcessWSRequest">
     <wsdl:part element="impl:signOnProcessWS" name="parameters">
    </wsdl:part>
 
  </wsdl:message>
 
   <wsdl:message name="getNestedBeanNamesResponse">
     <wsdl:part element="impl:getNestedBeanNamesResponse" name="parameters">
    </wsdl:part>
 
  </wsdl:message>
 
   <wsdl:message name="signOnProcessWSResponse">
     <wsdl:part element="impl:signOnProcessWSResponse" name="parameters">
    </wsdl:part>
 
  </wsdl:message>
 
   <wsdl:message name="getNestedBeanNamesRequest">
     <wsdl:part element="impl:getNestedBeanNames" name="parameters">
    </wsdl:part>
 
  </wsdl:message>
 
   <wsdl:portType name="Signon">
     <wsdl:operation name="getNestedBeanNames">
       <wsdl:input message="impl:getNestedBeanNamesRequest" name="getNestedBeanNamesRequest">
    </wsdl:input>
 
       <wsdl:output message="impl:getNestedBeanNamesResponse" name="getNestedBeanNamesResponse">
    </wsdl:output>
 
    </wsdl:operation>
 
     <wsdl:operation name="signOnProcessWS">
       <wsdl:input message="impl:signOnProcessWSRequest" name="signOnProcessWSRequest">
    </wsdl:input>
 
       <wsdl:output message="impl:signOnProcessWSResponse" name="signOnProcessWSResponse">
    </wsdl:output>
 
    </wsdl:operation>
 
  </wsdl:portType>
 
   <wsdl:binding name="SignonSoapBinding" type="impl:Signon">
 <wsaw:UsingAddressing xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" wsdl:required="false"/>
 
     <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
 
     <wsdl:operation name="getNestedBeanNames">
       <wsdlsoap:operation soapAction="getNestedBeanNames"/>
 
       <wsdl:input name="getNestedBeanNamesRequest">
         <wsdlsoap:body use="literal"/>
 
      </wsdl:input>
 
       <wsdl:output name="getNestedBeanNamesResponse">
         <wsdlsoap:body use="literal"/>
 
      </wsdl:output>
 
    </wsdl:operation>
 
     <wsdl:operation name="signOnProcessWS">
       <wsdlsoap:operation soapAction="signOnProcessWS"/>
 
       <wsdl:input name="signOnProcessWSRequest">
         <wsdlsoap:body use="literal"/>
 
      </wsdl:input>
 
       <wsdl:output name="signOnProcessWSResponse">
         <wsdlsoap:body use="literal"/>
 
      </wsdl:output>
 
    </wsdl:operation>
 
  </wsdl:binding>
 
   <wsdl:service name="SignonService">
     <wsdl:port binding="impl:SignonSoapBinding" name="Signon">
       <wsdlsoap:address location="http://localhost:9081/webservice/services/Signon"/>
 
    </wsdl:port>
 
  </wsdl:service>
 
</wsdl:definitions>

Next...

I create servlet Test for calling web service signon

package soap;
 
import java.io.IOException;
import java.net.URL;
 
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import javax.xml.ws.Service;
 
import webserviceclasses.Signon;
import webserviceclasses.SignonService;
import webserviceclasses.SignonServiceLocator;
import webserviceclasses.SignonSoapBindingStub;
import webserviceclasses.Signon_SignOn_Input_Properties;
import webserviceclasses.Signon_SignOn_Output_Properties;
 
 
 
/**
 * Servlet implementation class Test
 */
@WebServlet("/Test")
public class Test extends HttpServlet {
private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Test() {
        super();
        // TODO Auto-generated constructor stub
    }
 
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String v1 = request.getParameter("username");
String v2 = request.getParameter("password");
Signon_SignOn_Input_Properties in1 = new Signon_SignOn_Input_Properties();
Signon_SignOn_Output_Properties out1 = new Signon_SignOn_Output_Properties();
in1.setUsername(v1);
in1.setPassword(v2);
QName qName = new QName("http://webserviceclasses","SignonService");
URL url = new URL("http://localhost:9081/webservice/services/Signon?wsdl");
Service service = Service.create(url,qName);
Signon res = service.getPort(Signon.class);   // program stop running this line
res.signOnProcessWS(in1);
System.out.println("output  "+out1.getOutput());
}
}

And i got
Error 500: javax.xml.ws.WebServiceException: EndpointDescription: PortQName was null and could not be determined by runtime for class webserviceclasses.Signon; ServiceDescription: org.apache.axis2.jaxws.description.impl.ServiceDescriptionImpl

Could anyone help me pls????

 

Updated on 2014-07-20T06:08:29Z at 2014-07-20T06:08:29Z by PangSMS