[jboss-user] [JBossWS] - jbossws4ee call gsoap's webservice problem

peixubin do-not-reply at jboss.com
Thu Nov 16 20:19:16 EST 2006


I'm testing jbossws4ee client and gsoap server.(jbossws1.0.3 call gsoap's ws successly)

the gsoap service header file c2gWS.h:

  | //gsoap ns service name: C2g
  | //gsoap ns service style: document
  | //gsoap ns service encoding: literal
  | 
  | //gsoap ns service namespace: http://ydxt.c2g/wsdl
  | //gsoap ns service location:	http://localhost:8888/c2g.cgi
  | 
  | //gsoap ns schema namespace: urn:c2g
  | 
  | typedef char *	xsd__string;
  | typedef int	xsd__int;
  | typedef long	xsd__long;
  | typedef float	xsd__float;
  | typedef double	xsd__double;
  | 
  | struct ns__csb {
  |   xsd__int *id;
  |   xsd__string mc;
  |   xsd__string sbbm;
  |   xsd__int * dy;
  |   xsd__int * sblx; 
  |   xsd__double * xsl;
  |   xsd__double * gdl;
  |   xsd__double * sdl;
  |   xsd__double * edrl;
  |   xsd__double * yhrl;
  |   xsd__double * yhsl;
  |   xsd__string rq;
  |   xsd__string minrq;
  |   xsd__string maxrq;
  |   xsd__string glbz;
  | };
  | 
  | 
  | struct ns__csbArray {
  |   struct ns__csb * __ptr;
  |   int __size;
  |   int __offset; 
  | };
  | 
  | 
  | struct ns__C2gException {
  |   xsd__int *code;
  | };
  | 
  | 
  | ns__getGsb(char *dwdm,struct ns__csbArray *_input,struct ns__csbArray * _return) ;
  | ns__getSb(char *dwdm,struct ns__csbArray *_input,struct ns__csbArray * _return) ;
  | 

run soapcpp2 -1 -c c2gWS.h,generate c stub file and wsdl.
C2g.wsdl:


  | 
  | <?xml version="1.0" encoding="UTF-8"?>
  | <definitions name="C2g"
  |  targetNamespace="http://ydxt.c2g/wsdl"
  |  xmlns:tns="http://ydxt.c2g/wsdl"
  |  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  |  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  |  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  |  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  |  xmlns:ns="urn:c2g"
  |  xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"
  |  xmlns:MIME="http://schemas.xmlsoap.org/wsdl/mime/"
  |  xmlns:DIME="http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/"
  |  xmlns:WSDL="http://schemas.xmlsoap.org/wsdl/"
  |  xmlns="http://schemas.xmlsoap.org/wsdl/">
  | 
  | <types>
  | 
  |  <schema targetNamespace="urn:c2g"
  |   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  |   xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  |   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  |   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  |   xmlns:ns="urn:c2g"
  |   xmlns="http://www.w3.org/2001/XMLSchema"
  |   elementFormDefault="qualified"
  |   attributeFormDefault="qualified">
  |   <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
  |   <complexType name="csb">
  |    <sequence>
  |      <element name="id" type="xsd:int" minOccurs="0" maxOccurs="1" nillable="true"/>
  |      <element name="mc" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
  |      <element name="sbbm" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
  |      <element name="dy" type="xsd:int" minOccurs="0" maxOccurs="1" nillable="true"/>
  |      <element name="sblx" type="xsd:int" minOccurs="0" maxOccurs="1" nillable="true"/>
  |      <element name="xsl" type="xsd:double" minOccurs="0" maxOccurs="1" nillable="true"/>
  |      <element name="gdl" type="xsd:double" minOccurs="0" maxOccurs="1" nillable="true"/>
  |      <element name="sdl" type="xsd:double" minOccurs="0" maxOccurs="1" nillable="true"/>
  |      <element name="edrl" type="xsd:double" minOccurs="0" maxOccurs="1" nillable="true"/>
  |      <element name="yhrl" type="xsd:double" minOccurs="0" maxOccurs="1" nillable="true"/>
  |      <element name="yhsl" type="xsd:double" minOccurs="0" maxOccurs="1" nillable="true"/>
  |      <element name="rq" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
  |      <element name="minrq" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
  |      <element name="maxrq" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
  |      <element name="glbz" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
  |    </sequence>
  |   </complexType>
  |   <complexType name="csbArray">
  |    <sequence>
  |     <element name="item" type="ns:csb" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
  |    </sequence>
  |   </complexType>
  |   <complexType name="C2gException">
  |    <sequence>
  |      <element name="code" type="xsd:int" minOccurs="0" maxOccurs="1" nillable="true"/>
  |    </sequence>
  |   </complexType>
  |   <!-- operation request element -->
  |   <element name="getGsb">
  |    <complexType>
  |     <sequence>
  |      <element name="dwdm" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
  |      <element name="input" type="ns:csbArray" minOccurs="0" maxOccurs="1" nillable="true"/>
  |     </sequence>
  |    </complexType>
  |   </element>
  |   <!-- operation response element -->
  |   <element name="getGsbResponse">
  |    <complexType>
  |     <sequence>
  |      <element name="return" type="ns:csbArray" minOccurs="0" maxOccurs="1" nillable="true"/>
  |     </sequence>
  |    </complexType>
  |   </element>
  |   <!-- operation request element -->
  |   <element name="getSb">
  |    <complexType>
  |     <sequence>
  |      <element name="dwdm" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
  |      <element name="input" type="ns:csbArray" minOccurs="0" maxOccurs="1" nillable="true"/>
  |     </sequence>
  |    </complexType>
  |   </element>
  |   <!-- operation response element -->
  |   <element name="getSbResponse">
  |    <complexType>
  |     <sequence>
  |      <element name="return" type="ns:csbArray" minOccurs="0" maxOccurs="1" nillable="true"/>
  |     </sequence>
  |    </complexType>
  |   </element>
  |  </schema>
  | 
  | </types>
  | 
  | <message name="getGsbRequest">
  |  <part name="parameters" element="ns:getGsb"/>
  | </message>
  | 
  | <message name="getGsbResponse">
  |  <part name="parameters" element="ns:getGsbResponse"/>
  | </message>
  | 
  | <message name="getSbRequest">
  |  <part name="parameters" element="ns:getSb"/>
  | </message>
  | 
  | <message name="getSbResponse">
  |  <part name="parameters" element="ns:getSbResponse"/>
  | </message>
  | 
  | <portType name="C2gPortType">
  |  <operation name="getGsb">
  |   <documentation>Service definition of function ns__getGsb</documentation>
  |   <input message="tns:getGsbRequest"/>
  |   <output message="tns:getGsbResponse"/>
  |  </operation>
  |  <operation name="getSb">
  |   <documentation>Service definition of function ns__getSb</documentation>
  |   <input message="tns:getSbRequest"/>
  |   <output message="tns:getSbResponse"/>
  |  </operation>
  | </portType>
  | 
  | <binding name="C2g" type="tns:C2gPortType">
  |  <SOAP:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
  |  <operation name="getGsb">
  |   <SOAP:operation soapAction=""/>
  |   <input>
  |      <SOAP:body parts="parameters" use="literal"/>
  |   </input>
  |   <output>
  |      <SOAP:body parts="parameters" use="literal"/>
  |   </output>
  |  </operation>
  |  <operation name="getSb">
  |   <SOAP:operation soapAction=""/>
  |   <input>
  |      <SOAP:body parts="parameters" use="literal"/>
  |   </input>
  |   <output>
  |      <SOAP:body parts="parameters" use="literal"/>
  |   </output>
  |  </operation>
  | </binding>
  | 
  | <service name="C2g">
  |  <documentation>gSOAP 2.7.8c generated service definition</documentation>
  |  <port name="C2g" binding="tns:C2g">
  |   <SOAP:address location="http://localhost:8888/c2g.cgi"/>
  |  </port>
  | </service>
  | 
  | </definitions>
  | 

config.xml used by wscompile:

  | <?xml version="1.0" encoding="UTF-8"?>
  | 
  | <configuration
  |   xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
  | 
  |   <wsdl location="gen-src/C2g.wsdl"
  |     packageName="ydxt.c2g">
  |   </wsdl>
  | 
  | </configuration>
  | 
  | 


run wscompile -keep -f:documentliteral -f:wsi -import -mapping jaxrpc-mapping.xml config.xml,generate java stub file:
the C2G.java:


  | 
  | 
  | public interface C2G extends javax.xml.rpc.Service {
  |     public ydxt.c2g.C2GPortType getC2G() throws ServiceException;
  | }
  | 
  | 
  | 




the C2GPortType.java:


  | 
  | 
  | public interface C2GPortType extends java.rmi.Remote {
  |     public ydxt.c2g.GetGsbResponse getGsb(ydxt.c2g.GetGsb parameters) throws 
  |          java.rmi.RemoteException;
  |     public ydxt.c2g.GetSbResponse getSb(ydxt.c2g.GetSb parameters) throws 
  |          java.rmi.RemoteException;
  | }
  | 
  | 


ejb-jar.xml:

  | <?xml version="1.0"?>
  | <ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee"
  |   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  |   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
  |   version="2.1">
  | 
  | <enterprise-beans>
  | <session> 
  | <ejb-name>C2gSessionBean</ejb-name>
  | <home>ydxt.c2g.C2gSessionHome</home>
  | <remote>ydxt.c2g.C2gSession</remote>
  | <local-home>ydxt.c2g.C2gSessionLocalHome</local-home>
  | <local>ydxt.c2g.C2gSessionLocal</local>
  | <ejb-class>ydxt.c2g.C2gSessionBean</ejb-class>
  | <session-type>Stateless</session-type>
  | <transaction-type>Container</transaction-type>
  |       <service-ref>
  |         <service-ref-name>service/C2g</service-ref-name>
  |         <service-interface>ydxt.c2g.C2G</service-interface>
  |         <wsdl-file>META-INF/C2g.wsdl</wsdl-file>
  |         <jaxrpc-mapping-file>META-INF/jaxrpc-mapping.xml</jaxrpc-mapping-file>
  | <!--
  |     <port-component-ref>
  |       <service-endpoint-interface>ydxt.c2g.C2GPortType</service-endpoint-interface>
  |     </port-component-ref>
  | -->
  |       </service-ref>
  | 
  | </session>
  | </enterprise-beans>
  | </ejb-jar>
  | 
  | 
  |   | 
  |   | client code:
  |   | 
  |   |   | ...
  |   |   | 	GetGsbResponse res=null;
  |   |   | 	try {
  |   |   | 	    res=getService().getGsb(new GetGsb(dwdm,null));
  |   |   | 	} catch (Exception e) {
  |   |   | 	    e.printStackTrace();
  |   |   | 	    throw new C2GServerException(e.getMessage());
  |   |   | 	}
  |   |   | ...
  |   |   | 
  |   |   | 
  |   | 
  |   | 
  |   | when I call web service ,the jboss print error:
  |   | 08:53:55,761 DEBUG [ServiceProxy] Invoke on jaxrpc service: getPort
  |   | 08:53:55,761 DEBUG [PortProxy] Invoke on service endpoint interface: getGsb
  |   | 08:53:55,762 DEBUG [CallImpl] Fixing style: [was=rpc,is=document]
  |   | 08:53:55,762 DEBUG [CallImpl] Fixing use: [was=encoded,is=literal]
  |   | 08:53:55,764 DEBUG [ClientEngine] invoke: org.jboss.axis.MessageContext at 466b6f5
  |   | 08:53:55,764 DEBUG [HandlerChainBaseImpl] Create a handler chain for roles: null
  |   | 08:53:55,764 DEBUG [ClientEngine] Using handler chain for port: C2g
  |   | 08:53:55,764 DEBUG [HandlerChainBaseImpl] Create a handler chain for roles: null
  |   | 08:53:55,764 DEBUG [ClientEngine] Using empty handler chain
  |   | 08:53:55,764 DEBUG [HandlerChainBaseImpl] init: [config=null]
  |   | 08:53:55,764 DEBUG [HandlerChainBaseImpl] Enter: doHandleRequest
  |   | 08:53:55,764 DEBUG [HandlerChainBaseImpl] Exit: doHandleRequest with status: tru                  e
  |   | 08:53:55,774 DEBUG [HandlerChainBaseImpl] Enter: handleResponse
  |   | 08:53:55,774 DEBUG [HandlerChainBaseImpl] Exit: handleResponse with status: true
  |   | 08:53:55,791 ERROR [Call] Exception:
  |   | org.xml.sax.SAXException: Invalid element in ydxt.c2g.GetGsbResponse - return
  |   |         at org.jboss.axis.encoding.ser.BeanDeserializer.onStartChild(Ljava.lang.                  String;Ljava.lang.String;Ljava.lang.String;Lorg.xml.sax.Attributes;Lorg.jboss.ax                  is.encoding.DeserializationContext;)Lorg.jboss.axis.message.SOAPHandler;(BeanDes                  erializer.java:432)
  |   |         at org.jboss.axis.encoding.DeserializationContextImpl.startElement(Ljava                  .lang.String;Ljava.lang.String;Ljava.lang.String;Lorg.xml.sax.Attributes;)V(Dese                  rializationContextImpl.java:1168)
  |   | ...
  |   | 
  |   | 
  |   | gsoap send.log:
  |   | 
  |   |   | <?xml version="1.0" encoding="UTF-8"?>
  |   |   | <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns="urn:c2g"><SOAP-ENV:Body><ns:getGsbResponse>
  |   |   | <ns:return><ns:item><ns:id>1</ns:id><ns:mc>mc111</ns:mc><ns:sbbm>sbbm111</ns:sbbm><ns:dy>11</ns:dy><ns:sblx>12</ns:sblx><ns:xsl/><ns:gdl/><ns:sdl/><ns:edrl/><ns:yhrl/>
  |   |   | <ns:yhsl/><ns:rq/><ns:minrq/><ns:maxrq/><ns:glbz/></ns:item><ns:item><ns:id>2</ns:id><ns:mc>mc222</ns:mc><ns:sbbm>sbbm222</ns:sbbm><ns:dy>21</ns:dy>
  |   |   | <ns:sblx>22</ns:sblx><ns:xsl/>
  |   |   | <ns:gdl/><ns:sdl/><ns:edrl/><ns:yhrl/><ns:yhsl/><ns:rq/><ns:minrq/><ns:maxrq/><ns:glbz/></ns:item></ns:return></ns:getGsbResponse>
  |   |   | </SOAP-ENV:Body></SOAP-ENV:Envelope>
  |   |   | 
  |   |   | 
  |   |   | 
  |   | 
  |   | 
  |   | 
  |   | gsoap recv.log:
  |   | 
  |   |   | <?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>
  |   |   |   <ns1:getGsb xmlns:ns1="urn:c2g">
  |   |   |    <dwdm>335401</dwdm>
  |   |   |    <input xsi:nil="1"/>
  |   |   |   </ns1:getGsb>
  |   |   |  </soapenv:Body>
  |   |   | </soapenv:Envelope>
  |   |   | 
  |   |   | 
  |   | 
  |   | 
  |   | help me!

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3986718#3986718

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3986718



More information about the jboss-user mailing list