我正在写一篇VB.Net
Private Function generateXMLSchema()
Dim generatedXmlSchema As String = "<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:glob="http://sap.com/xi/SAPGlobal20/Global"><soapenv:Header/>" & _
"<soapenv:Body>" & _
"<glob:RouteBundleMaintainRequest_sync_V1>" & _
"<Route actionCode="01">" & _
"<Name>tEST 250502</Name>" & _
"<RouteTypeCode>2</RouteTypeCode>" & _
"</Route>" & _
"</glob:RouteBundleMaintainRequest_sync_V1>" & _
"</soapenv:Body>" & _
"</soapenv:Envelope>"
Return generatedXmlSchema
End Function
在Return generatedXmlSchema
我收到错误: generatedXmlSchema未声明。由于保护级别
有人可以告诉我这个问题吗?
更新了Double Quote,仍然是同样的错误
Private Function generateXMLSchema()
Dim genXmlSchema As String = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:glob=""http://sap.com/xi/SAPGlobal20/Global"><soapenv:Header/>" & _
"<soapenv:Body>" & _
"<glob:RouteBundleMaintainRequest_sync_V1>" & _
"<Route actionCode="01">" & _
"<Name>tEST 250502</Name>" & _
"<RouteTypeCode>2</RouteTypeCode>" & _
"</Route>" & _
"</glob:RouteBundleMaintainRequest_sync_V1>" & _
"</soapenv:Body>" & _
"</soapenv:Envelope>"
Return genXmlSchema
End Function
答案 0 :(得分:2)
您必须将每次出现的引号双引号作为字符串分隔符:
"http://schemas.xmlsoap.org/soap/envelope/" -> ""http://schemas.xmlsoap.org/soap/envelope/""
"http://sap.com/xi/SAPGlobal20/Global" -> ""http://sap.com/xi/SAPGlobal20/Global""
"01" -> ""01""
说,这个函数是Private
所以必须在它所属的Class
内调用
以上所有内容如下:
Public Class Class1
Sub main()
Console.WriteLine(generateXMLSchema())
End Sub
Private Function generateXMLSchema()
Dim generatedXmlSchema As String = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:glob=""http://sap.com/xi/SAPGlobal20/Global""><soapenv:Header/>" &
"<soapenv:Body>" &
"<glob:RouteBundleMaintainRequest_sync_V1>" &
"<Route actionCode=""01"">" &
"<Name>tEST 250502</Name>" &
"<RouteTypeCode>2</RouteTypeCode>" &
"</Route>" &
"</glob:RouteBundleMaintainRequest_sync_V1>" &
"</soapenv:Body>" &
"</soapenv:Envelope>"
Return generatedXmlSchema
End Function
End Class