当前位置:编程学习 > JAVA >>

axis 调用cxf 自定义对象怎么掉啊 着急请各位高手看看

接口:
 
import javax.activation.DataHandler;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.WebMethod;

@WebService
public inte易做图ce UploadFileService {
@WebMethod
public boolean uploadFile(@WebParam(name = "fileUpload")
FileUpload fileUpload);
}
FileUpload 类
import javax.activation.DataHandler;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlMimeType;
@XmlAccessorType(XmlAccessType.FIELD) 
public class FileUpload {
private String fileName; 
@XmlMimeType("application/octet-stream")  
private DataHandler dataHandler;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public DataHandler getDataHandler() {
return dataHandler;
}
public void setDataHandler(DataHandler dataHandler) {
this.dataHandler = dataHandler;

}
客户端 String endpoint="http://ws.uip.highsoft";
   fielCall.setOperationName(new QName(endpoint, method)); 
   
   DataHandler dh=new DataHandler(new FileDataSource(new File(filePath)));
   
   QName qName=new QName("tns:UploadFileService", "FileUpload");这个地方怎么写啊
   call.registerTypeMapping(FileUpload.class, qName, new BeanSerializerFactory(FileUpload.class, qName), new BeanDeserializerFactory(FileUpload.class,qName));这句话报空指针
   String[] nameArray = names.split(",|,");
   /*fielCall.addParameter(nameArray[0],Constants.XSD_BASE64, ParameterMode.IN);
   fielCall.addParameter(nameArray[1], Constants.XSD_STRING,ParameterMode.IN);*/
   fielCall.setReturnType(Constants.SOAP_BOOLEAN);
   FileUpload fileUpload=new FileUpload();
   fileUpload.setDataHandler(dh);
   fileUpload.setFileName(fileName);
   boolean flag=(Boolean)fielCall.invoke(new Object[]{fileUpload});



wsdl
<?xml version="1.0" encoding="utf-8" ?> 
- <wsdl:definitions name="UploadFileServiceImplService" targetNamespace="http://ws.uip.highsoft/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.uip.highsoft/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <wsdl:types>
- <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://ws.uip.highsoft/" xmlns="http://ws.uip.highsoft/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:complexType name="fileUpload">
- <xs:sequence>
  <xs:element minOccurs="0" name="fileName" type="xs:string" /> 
  <xs:element minOccurs="0" name="dataHandler" ns1:expectedContentTypes="application/octet-stream" type="xs:base64Binary" xmlns:ns1="http://www.w3.org/2005/05/xmlmime" /> 
  </xs:sequence>
  </xs:complexType>
  <xs:element name="uploadFile" type="uploadFile" /> 
- <xs:complexType name="uploadFile">
- <xs:sequence>
  <xs:element minOccurs="0" name="fileUpload" type="fileUpload" /> 
  </xs:sequence>
  </xs:complexType>
  <xs:element name="uploadFileResponse" type="uploadFileResponse" /> 
+ <xs:complexType name="uploadFileResponse">
- <xs:sequence>
  <xs:element name="return" type="xs:boolean" /> 
  </xs:sequence>
  </xs:complexType>
  </xs:schema>
  </wsdl:types>
- <wsdl:message name="uploadFileResponse">
  <wsdl:part element="tns:uploadFileResponse" name="parameters" /> 
  </wsdl:message>
- <wsdl:message name="uploadFile">
  <wsdl:part element="tns:uploadFile" name="parameters" /> 
  </wsdl:message>
- <wsdl:portType name="UploadFileService">
- <wsdl:operation name="uploadFile">
  <wsdl:input message="tns:uploadFile" name="uploadFile" /> 
  <wsdl:output message="tns:uploadFileResponse" name="uploadFileResponse" /> 
  </wsdl:operation>
  </wsdl:portType>
- <wsdl:binding name="UploadFileServiceImplServiceSoapBinding" type="tns:UploadFileService">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
- <wsdl:operation name="uploadFile">
  <soap:operation soapAction="" style="document" /> 
- <wsdl:input name="uploadFile">
  <soap:body use="literal" /> 
  </wsdl:input>
- <wsdl:output name="uploadFileResponse">
  <soap:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
+ <wsdl:service name="UploadFileServiceImplService">
- <wsdl:port binding="tns:UploadFileServiceImplServiceSoapBinding" name="UploadFileServiceImplPort">
  <soap:address location="http://localhost:7001/UIP/service/UploadFileService" /> 
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>

--------------------编程问答-------------------- 各位高手给看看,在线等
补充:Java ,  Java EE
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,