将参数从.Net传递给Java方法

时间:2016-06-05 11:02:58

标签: java c# xml

我已将一个程序集添加到.Net API解决方案中。汇编代码用java语言编写。 在程序集中有一个方法,其中方法需要Item参数,如下所述

public partial class ValueType : object, System.ComponentModel.INotifyPropertyChanged {

        private object itemField;   
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("Text", typeof(string), Order=0)]
        [System.Xml.Serialization.XmlElementAttribute("XmlDoc", typeof(object), Order=0)]
        public object Item {
            get {
                return this.itemField;
            }
            set {
                this.itemField = value;
                this.RaisePropertyChanged("Item");
            }
        }

我正在尝试将xmldoument类型对象作为参数传递给方法但是低于错误

public XmlDocument connectToBMC(XmlDocument xml)
{           
            try
            {                      
               Item.Input =xml ;
               Out= client.executeProcess("MyGrid", ":BMC_PS-SA-Tests:Mediation_layer_test", Item);
            }
            catch(Exception ex)
            {
                logger.Debug(ex.Message);
            }
            return xml;
}

错误:

There was an error in serializing body of message executeProcessRequest:'There was an error generating the XML document.'. 

inner exception

堆栈追踪:

  

服务器堆栈跟踪:          在System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.SerializeBody(XmlDictionaryWriter)   writer,MessageVersion版本,字符串操作,MessageDescription   messageDescription,Object returnValue,Object [] parameters,Boolean   isRequest)          在System.ServiceModel.Dispatcher.OperationFormatter.SerializeBodyContents(XmlDictionaryWriter)   writer,MessageVersion版本,Object []参数,Object   returnValue,Boolean isRequest)          在System.ServiceModel.Dispatcher.OperationFormatter.OperationFormatterMessage.OperationFormatterBodyWriter.OnWriteBodyContents(XmlDictionaryWriter)   作家)          在System.ServiceModel.Channels.BodyWriterMessage.OnWriteBodyContents(XmlDictionaryWriter)   作家)          在System.ServiceModel.Channels.Message.OnWriteMessage(XmlDictionaryWriter)   作家)          在System.ServiceModel.Channels.BufferedMessageWriter.WriteMessage(消息   消息,BufferManager bufferManager,Int32 initialOffset,Int32   maxSizeQuota)          at System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.WriteMessage(Message   消息,Int32 maxMessageSize,BufferManager bufferManager,Int32   messageOffset)          在System.ServiceModel.Channels.HttpOutput.SerializeBufferedMessage(消息   message,Boolean shouldRecycleBuffer)          在System.ServiceModel.Channels.HttpOutput.Send(TimeSpan超时)          at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.SendRequest(Message   消息,TimeSpan超时)          在System.ServiceModel.Channels.RequestChannel.Request(消息消息,TimeSpan超时)          在System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息   消息,TimeSpan超时)          在System.ServiceModel.Channels.ServiceChannel.Call(String action,Boolean oneway,ProxyOperationRuntime operation,Object [] ins,   对象[]输出,TimeSpan超时)          在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage)   methodCall,ProxyOperationRuntime操作)          在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage   消息)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
     

reqMsg,IMessage retMsg)          在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp;   msgData,Int32类型)          在MediationAPI.BusinessLogic.BMCServiceProxy.OrchestratorService.executeProcess(executeProcessRequest)   请求)          在MediationAPI.BusinessLogic.BMCServiceProxy.OrchestratorServiceClient.MediationAPI.BusinessLogic.BMCServiceProxy.OrchestratorService.executeProcess(executeProcessRequest)   请求)在C:\ Rahul   比斯瓦斯\ MediationAPI \ MediationAPI.BusinessLogic \服务   参考文献\ BMCServiceProxy \ Reference.cs:第1573行          at MediationAPI.BusinessLogic.BMCServiceProxy.OrchestratorServiceClient.executeProcess(String   C:\ Rahul中的gridName,String processName,ParametersType参数)   比斯瓦斯\ MediationAPI \ MediationAPI.BusinessLogic \服务   参考文献\ BMCServiceProxy \ Reference.cs:第1581行          在MediationAPI.BusinessLogic.BMCMessageHandler.connectToBMC(XmlDocument)   x:)在C:\ Rahul中   比斯瓦斯\ MediationAPI \ MediationAPI.BusinessLogic \ BMCMessageHandler.cs:行   65

尝试传递字符串xmldoc。 OuterXml喜欢字符串作为方法的参数,但得到以下错误

string xml1 = xml.OuterXml;

        try
        {                      
           pt.Input =xml1  ;
           pt = client.executeProcess("MyGrid", ":BMC_PS-SA-Tests:Mediation_layer_test", Item);
        }
        catch(Exception ex)
        {
            logger.Debug(ex.Message);
        }
        return xml;

错误:

  

java.lang.IllegalArgumentException堆栈跟踪:

Server stack trace: 
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime
     

操作,ProxyRpc&amp; RPC)          在System.ServiceModel.Channels.ServiceChannel.Call(String action,Boolean oneway,ProxyOperationRuntime operation,Object [] ins,   对象[]输出,TimeSpan超时)          在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage)   methodCall,ProxyOperationRuntime操作)          在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage   消息)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
     

reqMsg,IMessage retMsg)          在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp;   msgData,Int32类型)          在MediationAPI.BusinessLogic.BMCServiceProxy.OrchestratorService.executeProcess(executeProcessRequest)   请求)          在MediationAPI.BusinessLogic.BMCServiceProxy.OrchestratorServiceClient.MediationAPI.BusinessLogic.BMCServiceProxy.OrchestratorService.executeProcess(executeProcessRequest)   请求)在C:\ Rahul   比斯瓦斯\ MediationAPI \ MediationAPI.BusinessLogic \服务   参考文献\ BMCServiceProxy \ Reference.cs:第1573行          at MediationAPI.BusinessLogic.BMCServiceProxy.OrchestratorServiceClient.executeProcess(String   C:\ Rahul中的gridName,String processName,ParametersType参数)   比斯瓦斯\ MediationAPI \ MediationAPI.BusinessLogic \服务   参考文献\ BMCServiceProxy \ Reference.cs:第1581行          在MediationAPI.BusinessLogic.BMCMessageHandler.connectToBMC(XmlDocument)   x:)在C:\ Rahul中   比斯瓦斯\ MediationAPI \ MediationAPI.BusinessLogic \ BMCMessageHandler.cs:行   65

xml.OuterXml实际上是contanis

<root><event><event_action>closeIncident</event_action><entity_id>e9cf1bfcd5275100cc5ce0c8d463e486</entity_id><source_system></source_system><sent_timestamp></sent_timestamp></event><incidentRecord><caused_code><name>Testing</name></caused_code><resolution_category><name> Testing </name></resolution_category><resolution_subcategory><name> Testing </name></resolution_subcategory><resolved_by><user_id>Devi Nair</user_id></resolved_by><close_code>Closed/Resolved by Caller</close_code><closed_at>2016-05-24 14:00:06</closed_at><knowledge>false</knowledge><resolved_at>20-04-2016 15:41:36</resolved_at><mitigation_notes></mitigation_notes><close_notes>test</close_notes><mitigation_reason></mitigation_reason><resolve_children></resolve_children><mitigation_date></mitigation_date><external_entity_id>621943</external_entity_id><number>SNI0063168</number><caller><user_id>aglsd@agl.com.au</user_id></caller><status>7</status><status_reason>Confirmed</status_reason><requested_for><user_id>aglsd@agl.com.au</user_id></requested_for><organisation><code>4758</code></organisation><impact>2</impact><urgency>4</urgency><configuration_item><code></code></configuration_item><location><name>AGL Kolkata</name></location><service_type><name>Other</name></service_type><symptom><name></name></symptom><incident_type>Enquiry</incident_type><short_description>s</short_description><description></description><additional_comments></additional_comments><parent_incident><number></number><external_entity_id></external_entity_id></parent_incident><problem><number></number><external_entity_id></external_entity_id></problem><change_request><number></number><external_entity_id></external_entity_id></change_request><caused_by_change><number></number><external_entity_id></external_entity_id></caused_by_change><directed_from_kb><number></number></directed_from_kb><watch_lists><watch_list><user_id>d791017</user_id></watch_list></watch_lists><attachments><attachment><filename></filename><content></content></attachment></attachments><affectedCIs><affected_ci><name></name><code></code><organisation><code></code></organisation></affected_ci></affectedCIs><priority>3</priority></incidentRecord></root>";

任何人都可以帮我理解这个问题吗?

0 个答案:

没有答案