大伙帮我看个错误呢?在线等,十万火急

wunaigang 2004-12-23 10:23:17
直接从网上下的处理附件的ws服务器端,调试通过但
http://localhost:8080/UniformInterface/services/DataHead?wsdl 时出错
wsdd节点内容
<service name="DataHead" provider="java:RPC">
<!-- 服务类名 -->
<parameter name="className" value="com.sisytech.sdc.uf.GetImageByAttachment"/>
<!-- 允许访问所有方法 -->
<parameter name="allowedMethods" value="*"/>
</service>
/*
* Created on 2004-12-22
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package com.sisytech.sdc.uf;

/**
* @author Administrator
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
//import org.apache.soap.util.mime.*;
import java.net.*;
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.xml.soap.*;
import javax.activation.DataHandler;
import javax.xml.messaging.*;
import javax.xml.transform.stream.StreamSource;

public class GetImageByAttachment extends JAXMServlet implements ReqRespListener{
public SOAPMessage onMessage(SOAPMessage message){
try {
message.writeTo(System.out);
//以下部分创建SOAP消息
SOAPConnectionFactory soapConnectionFactory = javax.xml.soap.SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection = soapConnectionFactory.createConnection();

MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope requestEnvelope = soapPart.getEnvelope();
SOAPBody body = requestEnvelope.getBody();
SOAPBodyElement operation = body.addBodyElement(requestEnvelope.createName("image"));
//创建附件
URL url = new URL("http://localhost:8080/axis/test.jpg");//图像文件的储存的位置
DataHandler dh = new DataHandler(url);
AttachmentPart attachment2 = message.createAttachmentPart(dh);
attachment2.setContentId("myImage");//使用JAF来创建SOAP mime附件

soapMessage.addAttachmentPart(attachment2);
soapMessage.writeTo(System.out);
soapMessage.saveChanges();
return soapMessage;
} catch(Exception ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();
return null;
}
}

}


AXIS error
Sorry, something seems to have gone wrong... here are the details:

Fault - ; nested exception is:
WSDLException: faultCode=OTHER_ERROR: Can't find prefix for 'http://soap.xml.javax'. Namespace prefixes must be set on the Definition object using the addNamespace(...) method.:
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: WSDLException: faultCode=OTHER_ERROR: Can't find prefix for 'http://soap.xml.javax'. Namespace prefixes must be set on the Definition object using the addNamespace(...) method.:
faultActor:
faultNode:
faultDetail:

...全文
141 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
usabcd 2004-12-24
  • 打赏
  • 举报
回复
楼主用的是SAAJ 方式,拼装半天,比较繁琐,应该直接系列化 DataHandler,
内容仅 1 行:

public DataHandler getFile() throws Exception{
return new DataHandler(new FileDataSource(new File("test.jpg")));
}

别忘了在wsdd中注册 DataHandler, 方法参考axis的例子。
wunaigang 2004-12-23
  • 打赏
  • 举报
回复
大家有没有碰到过这样的问题呢
Jacky1206 2004-12-23
  • 打赏
  • 举报
回复
错误的意思好像是不能发现 'http://soap.xml.javax' 的前缀!可能需要你把这个 前缀 加入到 名字空间 namespace 里面去,有点类似 c++ 的语法了呵呵
wunaigang 2004-12-23
  • 打赏
  • 举报
回复
是否需要在wsdd文件中注册什么呢?
wunaigang 2004-12-23
  • 打赏
  • 举报
回复
- The class javax.xml.soap.SOAPMessage is defined in a java or javax package and
cannot be converted into an xml schema type. An xml schema anyType will be use
d to define this class in the wsdl file.
这是resin上显示的错误
wunaigang 2004-12-23
  • 打赏
  • 举报
回复
自己先顶,大伙帮忙啦

67,550

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧