GetSubscriptionReq   req   =   new   GetSubscriptionReq();  
     req.setSrcDeviceID("281800");
     req.setSrcDeviceType(28);
     req.setStreamingNo("10050509033001002503");
     req.setUserID("02765666640");
     req.setUserIDType(3);
    
            //   init   server  
            String   endpoint   =   "http://133.0.89.141:5011/IsmpCrmEngineService";  
            Service   service   =   new   Service();  
            Call   call   =   (Call)service.createCall();  
            call.setTargetEndpointAddress(endpoint);  
            QName   qn   =   new   QName("urn:BeanService",   "GetSubscriptionReq");   /**这里我定义了自定义类型   TestData   **/  
            call.registerTypeMapping(GetSubscriptionReq.class,   qn,  
                new   BeanSerializerFactory(GetSubscriptionReq.class,   qn),  
                new   BeanDeserializerFactory(GetSubscriptionReq.class,   qn));  
            //set   data  
            call.setOperationName(new   QName("urn:PortalEngine",   "getSubscription"));/**这里我调用了   webservice   中的一个方法   setData   ,他的参数就是我刚提到的TestData**/  
            Object[]   params   =   new   Object[]   {   req   };  
            System.out.println("----   start   set   data   ----");   
            call.invoke(params);  
            System.out.println("----   end   set   data   ----");  
            //   get   data  
            call.setOperationName(new   QName("urn:TestService",   "getData"));  
            call.setReturnType(qn,   GetSubscriptionReq.class);  
            GetSubscriptionReq   resultData   =   (GetSubscriptionReq)call.invoke(new   Object[]   {});  
            System.out.println();  
            System.out.println();  
            System.out.println("----   get   data   ----");  
            System.out.println("---------   end   --------");  
          }   catch   (Exception   e)   {  
            e.printStackTrace();  
          }   

解决方案 »

  1.   

    这是上面代码的报错信息:
    ----   start   set   data   ----
    AxisFault
     faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
     faultSubcode: 
     faultString: org.xml.sax.SAXException: Bad envelope tag:  body
     faultActor: 
     faultNode: 
     faultDetail: 
    {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: Bad envelope tag:  body
    at org.apache.axis.message.EnvelopeBuilder.startElement(EnvelopeBuilder.java:71)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
    at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
    at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at org.yangyang.im.IMtest.main(IMtest.java:181) {http://xml.apache.org/axis/}hostname:20090309-1619org.xml.sax.SAXException: Bad envelope tag:  body
    at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:701)
    at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at org.yangyang.im.IMtest.main(IMtest.java:181)
    Caused by: org.xml.sax.SAXException: Bad envelope tag:  body
    at org.apache.axis.message.EnvelopeBuilder.startElement(EnvelopeBuilder.java:71)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
    at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
    ... 9 more
      

  2.   

    WSDL文件,分2次发:
    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://portalEngine.ismp.chinatelecom.com" xmlns:intf="http://portalEngine.ismp.chinatelecom.com" xmlns:tns1="http://req.portalEngine.ismp.chinatelecom.com" xmlns:tns2="http://rsp.portalEngine.ismp.chinatelecom.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://portalEngine.ismp.chinatelecom.com">
    <wsdl:types>
    <schema elementFormDefault="qualified" targetNamespace="http://req.portalEngine.ismp.chinatelecom.com" xmlns="http://www.w3.org/2001/XMLSchema">
    <import namespace="http://rsp.portalEngine.ismp.chinatelecom.com"/>
    <import namespace="http://portalEngine.ismp.chinatelecom.com"/>
    <complexType name="CreateSubscriptionReq">
    <sequence>
    <element name="DA" nillable="true" type="xsd:string"/>
    <element name="DAType" type="xsd:int"/>
    <element name="FA" nillable="true" type="xsd:string"/>
    <element name="FAType" type="xsd:int"/>
    <element name="ID" nillable="true" type="xsd:string"/>
    <element name="IDType" type="xsd:int"/>
    <element name="OA" nillable="true" type="xsd:string"/>
    <element name="OAType" type="xsd:int"/>
    <element name="chanelPlayerID" nillable="true" type="xsd:string"/>
    <element name="eventID" nillable="true" type="xsd:string" minOccurs="0"/>
    <element name="srcDeviceID" nillable="true" type="xsd:string"/>
    <element name="srcDeviceType" type="xsd:int"/>
    <element name="streamingNo" nillable="true" type="xsd:string"/>
    </sequence>
    </complexType>

    <complexType name="GetSubscriptionReq">
    <sequence>
    <element name="srcDeviceID" nillable="true" type="xsd:string"/>
    <element name="srcDeviceType" type="xsd:int"/>
    <element name="streamingNo" nillable="true" type="xsd:string"/>
    <element name="userID" nillable="true" type="xsd:string"/>
    <element name="userIDType" type="xsd:int"/>
    </sequence>
    </complexType>
    </schema>
    <schema elementFormDefault="qualified" targetNamespace="http://portalEngine.ismp.chinatelecom.com" xmlns="http://www.w3.org/2001/XMLSchema">
    <import namespace="http://req.portalEngine.ismp.chinatelecom.com"/>
    <import namespace="http://rsp.portalEngine.ismp.chinatelecom.com"/>
    <element name="createSubscriptionReq" type="tns1:CreateSubscriptionReq"/>
    <element name="createSubscriptionReturn" type="tns2:CreateSubscriptionRsp"/>
    <element name="getSubscriptionReq" type="tns1:GetSubscriptionReq"/>
    <complexType name="ArrayOf_tns2_SubInfo">
    <sequence>
    <element maxOccurs="unbounded" minOccurs="0" name="item" type="tns2:SubInfo"/>
    </sequence>
    </complexType>
    <element name="getSubscriptionReturn" type="tns2:GetSubscriptionRsp"/>
    <element name="withdrawAllSubscriptionReq" type="tns1:WithdrawAllSubscriptionReq"/>
    <element name="withdrawAllSubscriptionReturn" type="tns2:ResponseInfo"/>
    <element name="modifyPasswordReq" type="tns1:ModifyPasswordReq"/>
    <element name="modifyPasswordReturn" type="tns2:ResponseInfo"/>
    <element name="resetPasswordReq" type="tns1:ResetPasswordReq"/>
    <element name="resetPasswordReturn" type="tns2:ResponseInfo"/>
    <element name="readUserReq" type="tns1:ReadUserReq"/>
    <element name="readUserReturn" type="tns2:ReadUserRsp"/>
    <element name="modifyUserReq" type="tns1:ModifyUserReq"/>
    <element name="modifyUserReturn" type="tns2:ResponseInfo"/>
    <element name="authenticateUserReq" type="tns1:AuthenticateUserReq"/>
    <element name="authenticateUserReturn" type="tns2:AuthenticateUserRsp"/>
    <element name="authorizeUserReq" type="tns1:AuthorizeUserReq"/>
    <element name="authorizeUserReturn" type="tns2:AuthorizeUserRsp"/>
    <element name="querySubscriptionHistoryReq" type="tns1:QuerySubscriptionHistoryReq"/>
    <complexType name="ArrayOf_tns2_SubHistoryInfo">
    <sequence>
    <element maxOccurs="unbounded" minOccurs="0" name="item" type="tns2:SubHistoryInfo"/>
    </sequence>
    </complexType>
    <element name="querySubscriptionHistoryReturn" type="tns2:QuerySubscriptionHistoryRsp"/>
    <element name="useServiceReq" type="tns1:UseServiceReq"/>
    <element name="useServiceReturn" type="tns2:ResponseInfo"/>
    <element name="createUserReq" type="tns1:CreateUserReq"/>
    <element name="createUserReturn" type="tns2:ResponseInfo"/>
    </schema>
      

  3.   

    <schema elementFormDefault="qualified" targetNamespace="http://rsp.portalEngine.ismp.chinatelecom.com" xmlns="http://www.w3.org/2001/XMLSchema">
    <import namespace="http://req.portalEngine.ismp.chinatelecom.com"/>
    <import namespace="http://portalEngine.ismp.chinatelecom.com"/>
    <complexType name="CreateSubscriptionRsp">
    <sequence>
    <element name="effectiveTime" nillable="true" type="xsd:string"/>
    <element name="expireTime" nillable="true" type="xsd:string"/>
    <element name="resultCode" type="xsd:int"/>
    <element name="streamingNo" nillable="true" type="xsd:string"/>
    <element name="subscriptionID" nillable="true" type="xsd:string"/>
    </sequence>
    </complexType>
    <complexType name="GetSubscriptionRsp">
    <sequence>
    <element name="resultCode" type="xsd:int"/>
    <element name="streamingNo" nillable="true" type="xsd:string"/>
    <element name="subInfo" nillable="true" type="impl:ArrayOf_tns2_SubInfo"/>
    </sequence>
    </complexType>
    <complexType name="ResponseInfo">
    <sequence>
    <element name="resultCode" type="xsd:int"/>
    <element name="streamingNo" nillable="true" type="xsd:string"/>
    </sequence>
    </complexType>
    </schema>
    </wsdl:types>
    <wsdl:message name="getSubscriptionResponse">
    <wsdl:part name="getSubscriptionReturn" element="impl:getSubscriptionReturn"/>
    </wsdl:message>
    <wsdl:message name="getSubscriptionRequest">
    <wsdl:part name="getSubscriptionReq" element="impl:getSubscriptionReq"/>
    </wsdl:message>
    <wsdl:portType name="PortalEngine">
    <wsdl:operation name="createSubscription" parameterOrder="createSubscriptionReq">
    <wsdl:input name="createSubscriptionRequest" message="impl:createSubscriptionRequest"/>
    <wsdl:output name="createSubscriptionResponse" message="impl:createSubscriptionResponse"/>
    </wsdl:operation>
    <wsdl:operation name="withdrawSubscription" parameterOrder="withdrawSubscriptionReq">
    <wsdl:input name="withdrawSubscriptionRequest" message="impl:withdrawSubscriptionRequest"/>
    <wsdl:output name="withdrawSubscriptionResponse" message="impl:withdrawSubscriptionResponse"/>
    </wsdl:operation>
    <wsdl:operation name="getSubscription" parameterOrder="getSubscriptionReq">
    <wsdl:input name="getSubscriptionRequest" message="impl:getSubscriptionRequest"/>
    <wsdl:output name="getSubscriptionResponse" message="impl:getSubscriptionResponse"/>
    </wsdl:operation>
    <wsdl:operation name="withdrawAllSubscription" parameterOrder="withdrawAllSubscriptionReq">
    <wsdl:input name="withdrawAllSubscriptionRequest" message="impl:withdrawAllSubscriptionRequest"/>
    <wsdl:output name="withdrawAllSubscriptionResponse" message="impl:withdrawAllSubscriptionResponse"/>
    </wsdl:operation>
    <wsdl:operation name="modifyPassword" parameterOrder="modifyPasswordReq">
    <wsdl:input name="modifyPasswordRequest" message="impl:modifyPasswordRequest"/>
    <wsdl:output name="modifyPasswordResponse" message="impl:modifyPasswordResponse"/>
    </wsdl:operation>
    <wsdl:operation name="resetPassword" parameterOrder="resetPasswordReq">
    <wsdl:input name="resetPasswordRequest" message="impl:resetPasswordRequest"/>
    <wsdl:output name="resetPasswordResponse" message="impl:resetPasswordResponse"/>
    </wsdl:operation>
    <wsdl:operation name="readUser" parameterOrder="readUserReq">
    <wsdl:input name="readUserRequest" message="impl:readUserRequest"/>
    <wsdl:output name="readUserResponse" message="impl:readUserResponse"/>
    </wsdl:operation>
    <wsdl:operation name="modifyUser" parameterOrder="modifyUserReq">
    <wsdl:input name="modifyUserRequest" message="impl:modifyUserRequest"/>
    <wsdl:output name="modifyUserResponse" message="impl:modifyUserResponse"/>
    </wsdl:operation>
    <wsdl:operation name="authenticateUser" parameterOrder="authenticateUserReq">
    <wsdl:input name="authenticateUserRequest" message="impl:authenticateUserRequest"/>
    <wsdl:output name="authenticateUserResponse" message="impl:authenticateUserResponse"/>
    </wsdl:operation>
    <wsdl:operation name="authorizeUser" parameterOrder="authorizeUserReq">
    <wsdl:input name="authorizeUserRequest" message="impl:authorizeUserRequest"/>
    <wsdl:output name="authorizeUserResponse" message="impl:authorizeUserResponse"/>
    </wsdl:operation>
    <wsdl:operation name="querySubscriptionHistory" parameterOrder="querySubscriptionHistoryReq">
    <wsdl:input name="querySubscriptionHistoryRequest" message="impl:querySubscriptionHistoryRequest"/>
    <wsdl:output name="querySubscriptionHistoryResponse" message="impl:querySubscriptionHistoryResponse"/>
    </wsdl:operation>
    <wsdl:operation name="useService" parameterOrder="useServiceReq">
    <wsdl:input name="useServiceRequest" message="impl:useServiceRequest"/>
    <wsdl:output name="useServiceResponse" message="impl:useServiceResponse"/>
    </wsdl:operation>
    </wsdl:portType>