如何检查po号用户提交的是否与使用if语句的情况相同? [英] How to check if po number user submitted is the same as the one in the case using if statement?
本文介绍了如何检查po号用户提交的是否与使用if语句的情况相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想查看用户提交的po号码是否与使用if语句的情况相同。如果po号不相同,我想抛出异常PO号与案例中的号码不匹配
案例是保存的xml文件在objXmlCaseDoc中。
我的vb代码
选项 严格 开
选项 明确 开启
导入 System.Xml
公共 类 BcaPoRequests
共享 Sub Main()
Dim objMessageProcessor As 新 MessageProcessor
Dim objSchemasCollection As New Msc.Integration.MessageBroker.Library.v4.SchemasCollection
Dim ob jTransformsCollection As 新 Msc.Integration.MessageBroker.Library.v4.TransformsCollection
objMessageProcessor.ProcessInputQueue( False , False ,objSchemasCollection,objTransformsCollection)
结束 Sub
私有 类 MessageProcessor
继承 Msc.Integration.ServiceCatalog.Library.v4.SoapMessageProcessor
受保护的 覆盖 Sub ProcessMessage( ByRef aobjBroker As ServiceCatalog.Library.v4.Broker, ByRef aobjXMLIn putSoapEnvelopeDoc As System.Xml.XmlDocument, ByRef aobjInstantiatedObjectsCollection As Microsoft.VisualBasic.Collection, ByRef aobjConsumer As ServiceCatalog.Library.v4.Consumer)
MyBase .ProcessMessage(aobjBroker,aobjXMLInputSoapEnvelopeDoc,aobjInstantiatedObjectsCollection,aobjConsumer)
Dim objXmlMessageDoc As XmlDocument
Dim objXmlMessageNode As XmlNode
Dim objNameTable As NameTable
Dim objXMLNameSpaceManager As XmlNamespac eManager
Dim objXMLSchemaException As Xml.Schema.XmlSchemaException
Dim strCaseNumber As String
Dim strPoNumber As String
Dim objXmlCaseDoc As XmlDocument
Dim objXmlResponseDoc As XmlDocument
Dim mobjSchemasLock As 新 对象
Dim objXMLOutputSoapEnvelopeDoc As XmlDocum ent
' 创建用于查询inputmessage的命名空间管理器(因为命名空间)
objNameTable = 新 NameTable
objXMLNameSpaceManager = 新 XmlNamespaceManager(objNameTable)
objXMLNameSpaceManager.AddNamespace( ext, http://www.courts.state.mn.us/ProtectionOrderExtension/1.0)
objXMLNameSpaceManager.AddNamespace( exc, http://www.courts.state.mn.us/ProtectionOrderQuery/1.0)
objXMLNameSpaceManager.AddNamespace( 皂, http://www.w3.org/2003/05/soap-envelope )
objXMLNameSpaceManager.AddNamespace( wsa, http://schemas.xmlsoap.org/ws/2004/08/addressing)
objXmlMessageNode = aobjXMLInputSoapEnvelopeDoc .DocumentElement.SelectSingleNode( soap:Body / exc:ProtectionOrderQueryRequest,objXMLNameSpaceManager)
objXmlMessageDoc = 新 XmlDocument
objXmlMessageDoc.LoadXml(objXmlMessageNode.OuterXml)
' 检查授权
' 验证输入消息
objXMLSchemaException = aobjBroker.ValidateXmlDocument(objXmlMessageDoc, ProtectionOrderQuery_1_0.xsd, NiemExchanges\ProtectionOrders\Exchange ,, False )
如果 不 objXMLSchemaException 没什么 然后
' 如果无效则返回错误
aobjBroker.Reply(aobjBroker.CreateSoapFault(Msc.Integration.Utility.Library.v4.Soap.udtSoapCodes.Sender,Msc.Integration。 Utility.Library.v4.Xml.FormatXmlSchemaValidationErrorText(objXMLSchemaException),Msc.Integration.Utility.Library.v4.Soap.udtSoapRoles.RoleUltimateReceiver,aobjXMLI nputSoapEnvelopeDoc, soap:InvalidMessage, soap:Body,Msc.Integration.Utility.Library.v4.Soap.GetReplyEndpointReference(aobjXMLInputSoapEnvelopeDoc),aobjXMLInputSoapEnvelopeDoc.DocumentElement.SelectSingleNode( soap:Header / wsa:MessageID,objXMLNameSpaceManager).InnerText,aobjConsumer))
退出 Sub
结束 如果
' 从中获取案例编号和采购订单编号输入消息
strCaseNumber = objXmlMessageDoc.DocumentElement.SelectSingleNode( ext:CourtFileNumber,objXMLNameSpaceManager).InnerText
strPoNumber = objXmlMessageDoc.DocumentElement.SelectSingleNode( ext:ProtectionOrderID,objXMLNameSpaceManager).InnerText
' 从Mncis获取案例信息
' 调用案例的代码
' 如果此案例中没有案例编号,请抓住错误
尝试
objXmlCaseDoc = Msc.Integration.Mncis.Library.v4。 Case .GetIxmlForCaseNumber(strCaseNumber, CourtCaseHeader,ProtectionOrder,SubjectParties,HearingTrialSetting,错误)
Catch ex As 例外
aobjBroker .Reply(aobjBroker.CreateSoapFault(Msc.Integration.Utility.Library.v4.Soap.udtSoapCodes.Sender,ex.Message,Msc.Integration.Utility.Library.v4.Soap.udtSoapRoles.RoleUltimateReceiver,aobjXMLInputSoapEnvelopeDoc, soap:InvalidMessage, soap:Body,Msc.Integration.Utility.Library.v4.Soap.GetReplyEndpointReference(aobjXMLInputSoapEnvelopeDoc),aobjXMLInputSoapEnvelopeDoc.DocumentElement.SelectSingleNode( soap:Header / wsa:MessageID,objXMLNameSpaceManager).InnerText,aobjConsumer))
退出 Sub
结束 尝试
' 检查PO是否在这种情况与用户提交的一样
' 如何使用if语句查看提交的PO是否与案例中的相同?
aobjBroker.Reply(aobjBroker.CreateSoapFault(Msc.Integration.Utility.Library.v4。 Soap.udtSoapCodes.Sender, Po不存在,Msc.Integration.Utility.Library.v4 .Soap.udtSoapRoles.RoleUltimateReceiver,aobjXMLInputSoapEnvelopeDoc, soap:InvalidMessage, soap:Body,Msc.Integration.Utility.Library.v4.Soap.GetReplyEndpointReference(aobjXMLInputSoapEnvelopeDoc),aobjXMLInputSoapEnvelopeDoc.DocumentElement.Sele ctSingleNode( soap:Header / wsa:MessageID,objXMLNameSpaceManager).InnerText,aobjConsumer))
' 退出子
' 结束尝试
结束 如果
' 将案例信息转换为输出格式
' 设置protectionOrderNumber
objXmlCaseDoc.DocumentElement.SetAttribute( protectionOrderNumber,strPoNumber)
' < span class =code-comment>运行样式表
objXmlResponseDo c = aobjBroker.TransformXmlDocument(objXmlCaseDoc, MNCIS_PO_BCA_Requests_1_0.xsl, BCA)
' 验证xml。验证回复消息
SyncLock mobjSchemasLock
objXMLSchemaException = aobjBroker.ValidateXmlDocument(objXmlCaseDoc, ProtectionOrderQuery_1_0.xsd, NiemExchanges \ProtectionOrders\Exchange ,, False )
结束 SyncLock
如果 不 objXMLSchemaException 没什么 然后
' 现在只在无效时记录警告
aobjBroker.LogApplicationEvent( 生成的答复无效: + objXMLSchemaException.Message,EventLogEntryType.Warning)
End 如果
' 创建SOAP信封以将回复返回给提交者
objXMLOutputSoapEnvelopeDoc = aobjBroker.CreateSoapEnvelope( http://www.courts.state.mn.us/ProtectionOrderQuery/1.0,_
Msc.Integration.Utility.Library.v4.Soap.GetReplyEndpointReference(aobjXMLInputSoapEnvelopeDoc),_
objXmlResponseDoc.DocumentElement ,, aobjConsumer,_
aobjXMLInputSoapEnvelopeDoc.DocumentElement.SelectSingleNode( soap:Header / wsa: MessageID,objXMLNameSpaceManager).InnerText)
' 将响应返回给请求者
aobjBroker.Reply(objXMLOutputSoapEnvelopeDoc)
结束 Sub
结束 类
结束 Class
解决方案
这就是我解决这个问题的方法
如果 objXmlCaseDoc.DocumentElement.SelectSingleNode( ProtectionOrder [ProtectionOrderNumber =' + strPoNumber + '] ,objXMLNameSpaceManager) 没什么 然后
aobjBroker.Reply(aobjBroker.CreateSoapFault(Msc.Integration.Utility.Library.v4.Soap.udtSoapCodes.Sender, < span class =code-string>保护顺序 + strPoNumber + for case + strCaseNumber + not found。,Msc.Integration.Utility.Library.v4.Soap。 udtSoapRoles.RoleUltimateReceiver,aobjXMLInputSoapEnvelopeDoc, soap:InvalidMessage, soap:Body,Msc.Integration.Utility.Library.v4.Soap.GetReplyEndpointReference(aobjXMLInputSoapEnvelopeDoc),aobjXMLInputSoapEnvelopeDoc.DocumentElement.SelectSingleNode( soap:Header / wsa:MessageID,objXMLNameSpaceManager).InnerText,aobjConsumer))
退出 Sub
结束 如果跨度>
I would like to check to see if the po number the user submitted is the same as the one in the case using if statement. If the po number is not the same, I want to throw an exception "PO Number does not match the one in the case"
The case is an xml document saved in objXmlCaseDoc.
My vb code
Option Strict On
Option Explicit On
Imports System.Xml
Public Class BcaPoRequests
Shared Sub Main()
Dim objMessageProcessor As New MessageProcessor
Dim objSchemasCollection As New Msc.Integration.MessageBroker.Library.v4.SchemasCollection
Dim objTransformsCollection As New Msc.Integration.MessageBroker.Library.v4.TransformsCollection
objMessageProcessor.ProcessInputQueue(False, False, objSchemasCollection, objTransformsCollection)
End Sub
Private Class MessageProcessor
Inherits Msc.Integration.ServiceCatalog.Library.v4.SoapMessageProcessor
Protected Overrides Sub ProcessMessage(ByRef aobjBroker As ServiceCatalog.Library.v4.Broker, ByRef aobjXMLInputSoapEnvelopeDoc As System.Xml.XmlDocument, ByRef aobjInstantiatedObjectsCollection As Microsoft.VisualBasic.Collection, ByRef aobjConsumer As ServiceCatalog.Library.v4.Consumer)
MyBase.ProcessMessage(aobjBroker, aobjXMLInputSoapEnvelopeDoc, aobjInstantiatedObjectsCollection, aobjConsumer)
Dim objXmlMessageDoc As XmlDocument
Dim objXmlMessageNode As XmlNode
Dim objNameTable As NameTable
Dim objXMLNameSpaceManager As XmlNamespaceManager
Dim objXMLSchemaException As Xml.Schema.XmlSchemaException
Dim strCaseNumber As String
Dim strPoNumber As String
Dim objXmlCaseDoc As XmlDocument
Dim objXmlResponseDoc As XmlDocument
Dim mobjSchemasLock As New Object
Dim objXMLOutputSoapEnvelopeDoc As XmlDocument
'create a namespace manager used for queries into inputmessage (because of namespace)
objNameTable = New NameTable
objXMLNameSpaceManager = New XmlNamespaceManager(objNameTable)
objXMLNameSpaceManager.AddNamespace("ext", "http://www.courts.state.mn.us/ProtectionOrderExtension/1.0")
objXMLNameSpaceManager.AddNamespace("exc", "http://www.courts.state.mn.us/ProtectionOrderQuery/1.0")
objXMLNameSpaceManager.AddNamespace("soap", "http://www.w3.org/2003/05/soap-envelope")
objXMLNameSpaceManager.AddNamespace("wsa", "http://schemas.xmlsoap.org/ws/2004/08/addressing")
objXmlMessageNode = aobjXMLInputSoapEnvelopeDoc.DocumentElement.SelectSingleNode("soap:Body/exc:ProtectionOrderQueryRequest", objXMLNameSpaceManager)
objXmlMessageDoc = New XmlDocument
objXmlMessageDoc.LoadXml(objXmlMessageNode.OuterXml)
'Check authorization
'Validate the input message
objXMLSchemaException = aobjBroker.ValidateXmlDocument(objXmlMessageDoc, "ProtectionOrderQuery_1_0.xsd", "NiemExchanges\ProtectionOrders\Exchange", , False)
If Not objXMLSchemaException Is Nothing Then
'return fault if invalid
aobjBroker.Reply(aobjBroker.CreateSoapFault(Msc.Integration.Utility.Library.v4.Soap.udtSoapCodes.Sender, Msc.Integration.Utility.Library.v4.Xml.FormatXmlSchemaValidationErrorText(objXMLSchemaException), Msc.Integration.Utility.Library.v4.Soap.udtSoapRoles.RoleUltimateReceiver, aobjXMLInputSoapEnvelopeDoc, "soap:InvalidMessage", "soap:Body", Msc.Integration.Utility.Library.v4.Soap.GetReplyEndpointReference(aobjXMLInputSoapEnvelopeDoc), aobjXMLInputSoapEnvelopeDoc.DocumentElement.SelectSingleNode("soap:Header/wsa:MessageID", objXMLNameSpaceManager).InnerText, aobjConsumer))
Exit Sub
End If
'Get the case number and the PO number from the input message
strCaseNumber = objXmlMessageDoc.DocumentElement.SelectSingleNode("ext:CourtFileNumber", objXMLNameSpaceManager).InnerText
strPoNumber = objXmlMessageDoc.DocumentElement.SelectSingleNode("ext:ProtectionOrderID", objXMLNameSpaceManager).InnerText
'Get the case information from Mncis
'Code for calling the case
'Catch the error if there is no case number on this case
Try
objXmlCaseDoc = Msc.Integration.Mncis.Library.v4.Case.GetIxmlForCaseNumber(strCaseNumber, "CourtCaseHeader,ProtectionOrder,SubjectParties,HearingTrialSetting", False)
Catch ex As Exception
aobjBroker.Reply(aobjBroker.CreateSoapFault(Msc.Integration.Utility.Library.v4.Soap.udtSoapCodes.Sender, ex.Message, Msc.Integration.Utility.Library.v4.Soap.udtSoapRoles.RoleUltimateReceiver, aobjXMLInputSoapEnvelopeDoc, "soap:InvalidMessage", "soap:Body", Msc.Integration.Utility.Library.v4.Soap.GetReplyEndpointReference(aobjXMLInputSoapEnvelopeDoc), aobjXMLInputSoapEnvelopeDoc.DocumentElement.SelectSingleNode("soap:Header/wsa:MessageID", objXMLNameSpaceManager).InnerText, aobjConsumer))
Exit Sub
End Try
'Check if the PO on this case is the same as the one user submitted
'How do I use a if statement to see if the PO submitted is the same as the one in the case?
aobjBroker.Reply(aobjBroker.CreateSoapFault(Msc.Integration.Utility.Library.v4.Soap.udtSoapCodes.Sender, "Po does not exist", Msc.Integration.Utility.Library.v4.Soap.udtSoapRoles.RoleUltimateReceiver, aobjXMLInputSoapEnvelopeDoc, "soap:InvalidMessage", "soap:Body", Msc.Integration.Utility.Library.v4.Soap.GetReplyEndpointReference(aobjXMLInputSoapEnvelopeDoc), aobjXMLInputSoapEnvelopeDoc.DocumentElement.SelectSingleNode("soap:Header/wsa:MessageID", objXMLNameSpaceManager).InnerText, aobjConsumer))
'Exit Sub
'End Try
End If
'Tranform case information into the output format
'set the protectionOrderNumber
objXmlCaseDoc.DocumentElement.SetAttribute("protectionOrderNumber", strPoNumber)
'Run stylesheet
objXmlResponseDoc = aobjBroker.TransformXmlDocument(objXmlCaseDoc, "MNCIS_PO_BCA_Requests_1_0.xsl", "BCA")
'Validate the xml. validate the reply message
SyncLock mobjSchemasLock
objXMLSchemaException = aobjBroker.ValidateXmlDocument(objXmlCaseDoc, "ProtectionOrderQuery_1_0.xsd", "NiemExchanges\ProtectionOrders\Exchange", , False)
End SyncLock
If Not objXMLSchemaException Is Nothing Then
'for now only log a warning if invalid
aobjBroker.LogApplicationEvent("Invalid Reply Generated: " + objXMLSchemaException.Message, EventLogEntryType.Warning)
End If
'Create the SOAP envelope to return the reply to the submitter
objXMLOutputSoapEnvelopeDoc = aobjBroker.CreateSoapEnvelope("http://www.courts.state.mn.us/ProtectionOrderQuery/1.0", _
Msc.Integration.Utility.Library.v4.Soap.GetReplyEndpointReference(aobjXMLInputSoapEnvelopeDoc), _
objXmlResponseDoc.DocumentElement, , aobjConsumer, _
aobjXMLInputSoapEnvelopeDoc.DocumentElement.SelectSingleNode("soap:Header/wsa:MessageID", objXMLNameSpaceManager).InnerText)
'Return the response to the requester
aobjBroker.Reply(objXMLOutputSoapEnvelopeDoc)
End Sub
End Class
End Class
解决方案
This is how I resolved this issue
If objXmlCaseDoc.DocumentElement.SelectSingleNode("ProtectionOrder[ProtectionOrderNumber='" + strPoNumber + "']", objXMLNameSpaceManager) Is Nothing Then aobjBroker.Reply(aobjBroker.CreateSoapFault(Msc.Integration.Utility.Library.v4.Soap.udtSoapCodes.Sender, "Protection Order " + strPoNumber + " for case " + strCaseNumber + " not found.", Msc.Integration.Utility.Library.v4.Soap.udtSoapRoles.RoleUltimateReceiver, aobjXMLInputSoapEnvelopeDoc, "soap:InvalidMessage", "soap:Body", Msc.Integration.Utility.Library.v4.Soap.GetReplyEndpointReference(aobjXMLInputSoapEnvelopeDoc), aobjXMLInputSoapEnvelopeDoc.DocumentElement.SelectSingleNode("soap:Header/wsa:MessageID", objXMLNameSpaceManager).InnerText, aobjConsumer)) Exit Sub End If
这篇关于如何检查po号用户提交的是否与使用if语句的情况相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文