JAX-RPC运行环境会生成,解析这样的SOAP Message
如果你要对生成好的,或解析的前的SOAP Message进行读取,更改,配置Handler(javax.xml.rpc.handler )截获Message,然后用SAAJ(SOAP with Attachments API for Java)进行操作。如果生成,解析的过程你要自己写的话,用SAAJ(javax.xml.soap )就可以。
先回答到这个程度,哪个地方需要详细的话,吱一声。觉得回答满意的话,记着给分。

解决方案 »

  1.   

    呵呵 放心 分肯定够的不够在给 
    我现在做的是华为给的一个接口 让我发送报文 和接收 然后解析
    我不知道需要怎么配置在网上看了axis但是需要改tomcat文件 我感觉没那么麻烦 我只是把生成的报文传到服务器然后接收他的请求在解析出来~请问下用哪些类可以实现这个流程
      

  2.   

    1,你的意思是Webservice的接口已经由华为提供了,现在你需要的就是一个客户端,我理解的对吗
    2,这个接口已经配置好了?还是需要你配置?
    3,提供一下service的信息,即wsdl文件的内容作为客户端的组件可以是J2EE,J2SE, J2ME的,如果接口服务已经可用(配置好了),
    除非你要用Servlet,EJB作为客户端,否则用不上App Server,你需要一个JAX-RPC运行环境
      

  3.   

    楼上兄弟对WebService好像颇有研究啊,想认识下,跟你学习学习!
    我MSN:[email protected]
    希望不啬赐教啊!呵呵
      

  4.   


      服务接口     接口方法名称           输入                   返回
    urn: KFWebService   ns__NEW_RECORD   见XML输入参数说明            见XML输出说明XML输入参数说明
    文件名称:
    KFWebService.NEW-RECORD.req.xml <?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:KFWebService">
     <SOAP-ENV:Body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <ns:NEW-RECORD>
       <NEW-RECORD>
        <SERVICECLASSID></SERVICECLASSID>
        <ACCEPTID></ACCEPTID>
        <USERNAME></USERNAME>
        <SERVICECITY></SERVICECITY>
        <ACCEPTPHONE></ACCEPTPHONE>
        <ACCEPTERNO></ACCEPTERNO>
        <CALLERNO></CALLERNO>
        <USERPHONE1></USERPHONE1>
        <CONTACTNAME></CONTACTNAME>
        <CONTACTID></CONTACTID>
        <FAXNO></FAXNO>
        <EMAIL></EMAIL>
        <ADDRESS></ADDRESS>
        <HOPEREPLYDATE></HOPEREPLYDATE>
        <SERVICETITLE></SERVICETITLE>
        <SERVICECONTENT></SERVICECONTENT>
        <URGENTID></URGENTID>
       </NEW-RECORD>
      </ns:NEW-RECORD>
     </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
      

  5.   

    没有WSDL文件吗?
    EndpointAddress是多少?ServiceFactory factory = ServiceFactory.newInstance();
    Service service = factory.createService(new QName("KFWebService"));QName port = new QName("<port name>");
    Call call = service.createCall(port);call.setTargetEndpointAddress("http://hostname:port/?????/?????");
    call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true));
    call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");
    call.setProperty(ENCODING_STYLE_PROPERTY, "http://schemas.xmlsoap.org/soap/encoding/");QName QNAME_TYPE_STRING = new QName("http://www.w3.org/2001/XMLSchema", "string");
    call.setReturnType(QNAME_TYPE_STRING);call.setOperationName(new QName("ns:NEW-RECORD", "ns__NEW_RECORD"));
    call.addParameter("String1", QNAME_TYPE_STRING, ParameterMode.IN);
    call.addParameter("String2", QNAME_TYPE_STRING, ParameterMode.IN);
    ........String[] params = { "p1","p2",.... };
    String result = (String) call.invoke(params);
      

  6.   

    <?xml version="1.0" encoding="UTF-8"?>
    <definitions name="KFWebService"
     xmlns="http://schemas.xmlsoap.org/wsdl/"
     xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"
     xmlns:WSDL="http://schemas.xmlsoap.org/wsdl/"
     targetNamespace="urn:KFWebService"
     xmlns:tns="urn:KFWebService"
     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:KFWebService"><types>
     <schema targetNamespace="urn:KFWebService"
      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:KFWebService"
      xmlns="http://www.w3.org/2001/XMLSchema"
      elementFormDefault="unqualified"
      attributeFormDefault="unqualified">  <complexType name="NewRecordRequest">
       <all>
        <element name="SERVICECLASSID" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="ACCEPTID" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="USERNAME" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="SERVICECITY" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="ACCEPTPHONE" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="ACCEPTERNO" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="CALLERNO" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="USERPHONE1" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="CONTACTNAME" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="CONTACTID" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="FAXNO" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="EMAIL" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="ADDRESS" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="HOPEREPLYDATE" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="SERVICETITLE" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="SERVICECONTENT" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="URGENTID" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
       </all>
      </complexType>  <complexType name="NewRecordReSponse">
       <all>
        <element name="SERIALNO" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="RET" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="ERRMSG" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
       </all>
      </complexType>  <complexType name="GetStateRequest">
       <all>
        <element name="SERIALNO" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="ServiceClassID" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
       </all>
      </complexType>  <complexType name="GetStateResponse">
       <all>
        <element name="NODEID" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="NODENAME" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="HANDLENOTES" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
        <element name="RET" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
       </all>
      </complexType> </schema>
    </types><message name="NEW-RECORDRequest">
     <part name="NEW-RECORD" type="ns:NewRecordRequest"/>
    </message><message name="NewRecordReSponse">
     <part name="SERIALNO" type="xsd:string"/>
     <part name="RET" type="xsd:string"/>
     <part name="ERRMSG" type="xsd:string"/>
    </message><message name="GET-STATERequest">
     <part name="GET-STATE" type="ns:GetStateRequest"/>
    </message><message name="GetStateResponse">
     <part name="NODEID" type="xsd:string"/>
     <part name="NODENAME" type="xsd:string"/>
     <part name="HANDLENOTES" type="xsd:string"/>
     <part name="RET" type="xsd:string"/>
    </message><portType name="KFWebServicePortType">
     <operation name="NEW-RECORD">
      <documentation>Service definition of function ns__NEW_RECORD</documentation>
      <input message="tns:NEW-RECORDRequest"/>
      <output message="tns:NewRecordReSponse"/>
     </operation>
     <operation name="GET-STATE">
      <documentation>Service definition of function ns__GET_STATE</documentation>
      <input message="tns:GET-STATERequest"/>
      <output message="tns:GetStateResponse"/>
     </operation>
    </portType><binding name="KFWebServiceBinding" type="tns:KFWebServicePortType">
     <SOAP:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
     <operation name="NEW-RECORD">
      <SOAP:operation soapAction="NEW_RECORD"/>
      <input>
       <SOAP:body use="encoded" namespace="urn:KFWebService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </input>
      <output>
       <SOAP:body use="encoded" namespace="urn:KFWebService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </output>
     </operation>
     <operation name="GET-STATE">
      <SOAP:operation soapAction="GET_STATE"/>
      <input>
       <SOAP:body use="encoded" namespace="urn:KFWebService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </input>
      <output>
       <SOAP:body use="encoded" namespace="urn:KFWebService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </output>
     </operation>
    </binding><service name="KFWebService">
     <documentation>KF web service program</documentation>
     <port name="KFWebService" binding="tns:KFWebServiceBinding">
      <SOAP:address location="http://localhost:8088"/>
     </port>
    </service></definitions>
      

  7.   

    方法一利用静态Stub
    1,创建config-wsdl.xml
    内容
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration 
      xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
      <wsdl location="./KFWebService.wsdl"
           packageName="staticstub"/>
    </configuration>
    你的wsdl和它同目录,名字为KFWebService.wsdl2,运行wscompile -gen:client config-wsdl.xml
    产生类文件如下
    GetStateRequest.class
    GetStateRequest_SOAPBuilder.class
    GetStateRequest_SOAPSerializer.class
    KFWebService.class
    KFWebServicePortType.class
    KFWebServicePortType_GET_2d_STATE_RequestStruct.class
    KFWebServicePortType_GET_2d_STATE_RequestStruct_SOAPBuilder.class
    KFWebServicePortType_GET_2d_STATE_RequestStruct_SOAPSerializer.class
    KFWebServicePortType_GET_2d_STATE_ResponseStruct.class
    KFWebServicePortType_GET_2d_STATE_ResponseStruct_SOAPBuilder.class
    KFWebServicePortType_GET_2d_STATE_ResponseStruct_SOAPSerializer.class
    KFWebServicePortType_NEW_2d_RECORD_RequestStruct.class
    KFWebServicePortType_NEW_2d_RECORD_RequestStruct_SOAPBuilder.class
    KFWebServicePortType_NEW_2d_RECORD_RequestStruct_SOAPSerializer.class
    KFWebServicePortType_NEW_2d_RECORD_ResponseStruct.class
    KFWebServicePortType_NEW_2d_RECORD_ResponseStruct_SOAPBuilder.class
    KFWebServicePortType_NEW_2d_RECORD_ResponseStruct_SOAPSerializer.class
    KFWebServicePortType_Stub.class
    KFWebService_Impl.class
    KFWebService_SerializerRegistry.class
    NewRecordRequest.class
    NewRecordRequest_SOAPBuilder.class
    NewRecordRequest_SOAPSerializer.class3,写你的客户端
    你的endpointAddress是多少,wsdl中的<SOAP:address location="http://localhost:8088"/>在部署时被应该盖掉,你在文档中找一下
    import javax.xml.rpc.Stub;
    import javax.xml.rpc.holders.StringHolder;
    import staticstub.KFWebServicePortType;
    import staticstub.KFWebService_Impl;
    import staticstub.NewRecordRequest;
    public class TestClient {
        public static void main(String[] args) {
         //what's you enpoint address
         String endpointAddress = "http://localhost:8088/?????";
            try {
                Stub stub = (Stub)(new KFWebService_Impl()).getKFWebService();
                stub._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY,endpointAddress);
                KFWebServicePortType port = (KFWebServicePortType) stub;
                //define request
                NewRecordRequest newRecordRequest = new NewRecordRequest();
                newRecordRequest.setACCEPTERNO("");
                newRecordRequest.setACCEPTID("");
                //.................
                //define more plsease..........
                
                //define return variables
                StringHolder serialno = new StringHolder();
                StringHolder red = new StringHolder();
                StringHolder errmsg = new StringHolder();
                //make a call
                port.NEWRECORD(newRecordRequest,serialno,red,errmsg);
                System.out.println(serialno);
                System.out.println(red);
                System.out.println(errmsg);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }当然你得有运行环境