首页 \ 问答 \ JAX-WS Web服务 - 将String中输入XML的一部分获取到字段中(JAX-WS web service - Get portion of input XML in String to a field)

JAX-WS Web服务 - 将String中输入XML的一部分获取到字段中(JAX-WS web service - Get portion of input XML in String to a field)

我有一个Java类,其方法是作为webservice方法公开的。 下面是我的Java类。

    @WebService
    public class TestService{

        public String testMethod(InputVO input) {

        }
    }

        public class InputVO{
           private Data data;

        }

        public class Data{
            private String xmlData;
        }

现在在我的InputVO中,我有一个Data字段,它有一个String xmlData。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:svc="http://test.svc.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <svc:testMethod>
         <arg0>
             <data>
               <!-- ANY XML CONTENT-->
            </data>
         </arg0>
      </svc:service>
   </soapenv:Body>
</soapenv:Envelope>

这是我的服务期望的输入XML文件的结构。 在数据元素内部,我应该能够传递任何XML内容。 现在在我的服务的testMethod ,我应该在XML格式的Data对象的xmlData元素中获取这些数据。 我已经为我的wsdl的xsd文件中的内容设置了内容。

 <xs:complexType name="data">
    <xs:sequence>
      <xs:any/>
    </xs:sequence>
  </xs:complexType>

但是当我在InputVO检查我的xmlData字段时,它将InputVO null。 如何将完整的String XML数据设置为xmlData字段? 请帮助我。


I have a Java class with a method exposed as a webservice method. Below is my Java class.

    @WebService
    public class TestService{

        public String testMethod(InputVO input) {

        }
    }

        public class InputVO{
           private Data data;

        }

        public class Data{
            private String xmlData;
        }

Now in my InputVO, I've a Data field which has a String xmlData.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:svc="http://test.svc.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <svc:testMethod>
         <arg0>
             <data>
               <!-- ANY XML CONTENT-->
            </data>
         </arg0>
      </svc:service>
   </soapenv:Body>
</soapenv:Envelope>

This is the structure of the Input XML file that my service expects. Inside the data element, I should be able to pass any XML content. Now in my service's testMethod, I should get this data in the XML format in xmlData element of Data object. I've set for the content inside data in the xsd file of my wsdl.

 <xs:complexType name="data">
    <xs:sequence>
      <xs:any/>
    </xs:sequence>
  </xs:complexType>

But when I check my xmlData field in InputVO, it is coming as null. How do I set the complete String XML data into xmlData field? Kindly help me.


原文:https://stackoverflow.com/questions/19935528
更新时间:2023-10-19 14:10

最满意答案

您必须通过将动态语言值传递给控制器​​来单独映射每个路由。 例如:

        routes.MapRoute(
            name: "News English",
            url: "News",
            defaults: new { controller = "Home", action = "News", language = "en-US"}
        );

        routes.MapRoute(
            name: "News Italian",
            url: "Notizie",
            defaults: new { controller = "Home", action = "News", language = "it-IT" }
        );

在你的控制器中,你可以获得语言,并用它做你想做的事情(例如设置当前的文化和当前的UI文化):

    public ActionResult News(string language)
    {
        System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(language);
        System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(language);

        //Do what you want

        return View();
    }

You have to map each route individually by passing a dynamic language value to the controller. For example:

        routes.MapRoute(
            name: "News English",
            url: "News",
            defaults: new { controller = "Home", action = "News", language = "en-US"}
        );

        routes.MapRoute(
            name: "News Italian",
            url: "Notizie",
            defaults: new { controller = "Home", action = "News", language = "it-IT" }
        );

and in your controller you can get the language and do what you want with it (for example set the current culture and current UI culture):

    public ActionResult News(string language)
    {
        System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(language);
        System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(language);

        //Do what you want

        return View();
    }

相关问答

更多
  • 以下是用户WeTTTT粘贴的正确答案。 我相信你的网站根目录下有一个“课程”文件夹,这会导致网址根本没有打到mvc路由。 解决此问题的一种快速方法是添加routes.RouteExistingFiles = true;,但这不是建议的,可能会导致其他问题。 您是否希望/允许将“课程”文件夹名称更改为绕过路由的其他内容? - WeTTTT 3月21日12:11 The following is pasted from user WeTTTT as was the correct answer. I belie ...
  • 如果您在ASP.NET之上使用Web API,它们最终将在相同的底层ASP.NET路由表上运行 - 但正如从用户角度指出的那样,您可以通过两种不同的方法来注册路由。 路由是这样设计的,因此当ASP.NET外部托管时,Web API不必依赖于System.Web。 请记住,Web API不是坐在MVC,Web窗体之上,或者是ASP.NET。 它可以在Web上下文(ASP.NET)中托管,但也可以是自托管(Console,WPF等),甚至托管在内存中(无端口使用,即轻量级的端到端测试)。 If you use ...
  • MapRoute只是一个更广义的Route.Add()的包装它是一个确切的扩展方法。 路由不是特定于MVC,因此允许您提供任何合适的路由。 这使得它非常灵活,并允许您实现自己的自定义RouteHandlers。 我在ASP.Net 3.5中为.aspx页面做了这个。 它看起来像这样: routes.Add("Blah", Route("custom/{stuff}", new SecretSauceRouteHandler())) MapRoute is just a wrapper around ...
  • 您必须通过将动态语言值传递给控制器来单独映射每个路由。 例如: routes.MapRoute( name: "News English", url: "News", defaults: new { controller = "Home", action = "News", language = "en-US"} ); routes.MapRoute( name: ...
  • 鉴于您提供的信息,我认为这两条路线都不符合要求。 MVC将寻找带有“id”参数的方法签名,并且您的操作方法没有。 如果请求实际上将您带到Home控制器上的Index方法,请检查某处的错误处理程序是否正在捕获该条件,然后将您重定向到/ Home / Index 如果按如下方式设置路由表,则第一个路由将根据需要进行匹配。 public static void RegisterRoutes(RouteCollection routes) { routes.MapRoute( name: "Ho ...
  • 它比表面变化更深。 找到了达米安博德对这个话题的参考, https://damienbod.com/2015/10/21/asp-net-5-mvc-6-localization/ https://github.com/damienbod/AspNet5Localization/tree/master/src/AspNetCoreLocalization 来源和他写的话题。 在解释中,它确实涉及与他展示的webapi相关的ActionFilter。 我认为它是你的一个起点。 Great news, fina ...
  • 实际上,我没有得到你要求的内容,但通过查看代码,这不是在MVC 3,4和5中创建/使用Areas的标准方式。 您不需要在每个控制器内写入逻辑并执行重定向。 在我的RouteConfig ,我通常只有默认的路由映射。 当你需要区域时,你可以在Visual Studio中右键点击MVC web项目,然后点击'添加 - >区域'。 这将在Web项目的根目录下的Areas文件夹内创建一个带有区域名称的文件夹。 在区域文件夹内,您应该找到区域名称和映射的AreaRegistration.cs 。 public cla ...
  • 首先,如果您使用相同的Http Verb(在您的情况下为GET),则不能重载控制器操作,因为您需要具有唯一的操作名称。 所以你需要以不同的方式命名你的行为: public class ProfileController : Controller { public ActionResult IndexKey( long? userkey ) { ... } public ActionResult IndexName( string username ) ...
  • 你想配置你的问题的第一部分的路线是: routes.MapRoute( "", "home/default.aspx", new { controller = "Home", action = "Default" } ); 假设你想用某种参数'浏览'default.aspx,你可以这样做: routes.MapRoute( "", "home/default.aspx/{param}", new { controller = "Home", action ...
  • 因为当您请求yourBaseUrl/Process/ ,它匹配路由模式{controller}/{action}/{id} ,这是您定义的第一个路由的url模式(名为Home路由模式)。 因此,它会尝试将请求发送到操作方法,并且由于您在请求url中没有操作方法段,它将尝试使用在该路由注册中定义的默认值,即Index 。 您正在获取404,因为您的ProcessController没有Index操作方法。 如果将一个Index()操作方法添加到ProcessController ,它将执行该操作并从中返回结果 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)