2012-02-25 25 views
1

用Netbeans向导编写了一个'webservice',运行在glassfish上。我添加了一个引用使用wsdl到我的.NET客户端,VB如果它有任何区别。VB.NET为glassfish编写的消费Web服务:SoapHeaderException

我明显不知道发生了什么,因为我遇到了一些砖墙。

问题是SoapHeaderException。

System.Web.Services.Protocols.SoapHeaderException: com/mysql/jdbc/Connection 
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(
     SoapClientMessage message, WebResponse response, Stream responseStream, 
     Boolean asyncCall) 
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(
     String methodName, Object[] parameters) 
at WSClient.WSClient.localhost.DatabaseGateService.createCustomerTable(String xml) 
      in C:\Project\WSClient\Web References\localhost\Reference.vb:line 40 
at WSClient.USAHWSClientConsumer.TestCustomer() in 
      C:\Project\WSClient\Client\WSConsumer.vb:line 22 

Web服务本身很简单:

@WebService() 
public class DatabaseGate { 
    private MySQLManagerImp manager; 

    public DatabaseGate(){ 
     manager = new MySQLManagerImp(); 
    } 

    @WebMethod(operationName = "createCustomerTable") 
    public void createCustomerTable(@WebParam(name = "xml") String xml) { 
     manager.createCustomersTable(xml); 
    } 
} 

它需要一个XML字符串,因为我不想在参数所憎恶的传递。

我试图通过简单实例Web引用消费服务:

Dim ws As localhost.DatabaseWS = New localhost.DatabaseWS 
// Create the xml string 
Dim qbCustomerQueryRS As String = qbQuery.GetCustomerQueryXML() 
Dim processedCustomerXML As String = 
    customerResponseParser.GetAllCustomerDatabaseFriendlyXML(qbCustomerQueryRS) 

ws.createCustomerTable(processedCustomerXML) 

我试过在SOAP信封中写入字符串,但仍然收到了同样的信息。所以传递一个字符串是kaputt,因为它应该是;为什么WS知道要解析一个字符串,并且简单地实例化并从对象中调用该方法,就好像它是本地的一样,并不像我认为的那样工作。

发生了什么事?

回答

1

听起来像WSDL引用com/mysql/jdbc/Connection,它不是.NET端已知的类。如果您可以控制Web服务,请添加注释以避免外部类引用的序列化(如com/mysql/jdbc/Connection)。如果您不这样做,只需将WSDL下载到文本文件,手动编辑它以删除此类/属性,然后重新创建指向编辑文件的引用。您可以稍后更改Web.config中的端点。

+0

看看?wsdl,我没有看到任何对Connection类的直接引用。我确实可以控制Web服务。我创建了一个非常简单的WS,没有外部引用,它起作用,所以你是对的。不幸的是,我不得不想知道为什么从客户的角度来看,WS所依赖的地方依赖关系是什么;它应该关心的是接收字符串是否正确?无论如何,我不知道如何添加正确的注释。交换SOAP消息时创建依赖关系的代码向导正在从我那里抽象出什么?谢谢回复。 – Danedo 2012-02-25 21:40:19

1

事实证明,我之所以接受

System.Web.Services.Protocols.SoapHeaderException: com/mysql/jdbc/Connection 

类似于迭戈的回答(谢谢你的指点我朝着正确的方向):参考的问题。

我假定我的WS部署工作正常,因为我测试了执行的方法,但只假设我需要通过线路成功传输的数据。

测试使用的是GlassFish另一个角度揭示:

Service invocation threw an exception with message : null; Refer to the server log for more details 

检查服务器日志,答案是显而易见的:

java.lang.NoClassDefFoundError: com/mysql/jdbc/Connection 

我忘了的jar添加到COM/MySQL的/ JDBC /连接。

+0

对不起,我没有时间回复您的评论。我很高兴你明白了。给予好评。 – Diego 2012-02-28 17:04:30