Webserver newspaper xfirefault:unmarshalling error:unexpected Element (uri: "http://server.m/", Loc__web

Source: Internet
Author: User
Tags soap wsdl

Today, with Xfire clients to access their own created webserver, the results of the call when the error, first look at the client's

Code:

/** * Project NAME:ASJGL * File Name:Main.java * Package Name:com.zsy.jsec.zdsjyj.util * date:2016-1-13 afternoon 08:21:16 * Copyri
Ght (c) 2016, syzhao@zsy.com all Rights Reserved.

* * * */package com.zsy.jsec.zdsjyj.util;
Import java.net.MalformedURLException;

Import Java.net.URL;
Import org.codehaus.xfire.client.Client;

Import Org.codehaus.xfire.service.Service; public class Main {/** * main: This describes the effect of this method in one sentence. <br/> * @author Syzhao * @param args * @since JDK 1.6/public static void Main (string[) AR
        GS) {Client client = NULL;
            try {client = new client (new URL ("http://localhost:8080/springwebserver/ws/HelloWorld?wsdl"));
            Service service = Client.getservice ();
            System.out.println (Service.getname ());
            
            object[] Result1 = Client.invoke ("SayHello", new object[] {"John"}); for (int i = 0; i < result1.length i++) {System.out.println (Result1[i]);
        } catch (Malformedurlexception e) {e.printstacktrace ();
        catch (Exception e) {e.printstacktrace ();
 }
        
    }
}

The above code is not wrong, is reported this error:

{http://server.zsy.com/} HelloWorldService org.codehaus.xfire.fault.XFireFault:Unmarshalling error:unexpected Element (uri: "http:// server.zsy.com/", Local:" arg0 "). Expected elements are <{}arg0> at Org.codehaus.xfire.fault.Soap11FaultSerializer.readMessage ( soap11faultserializer.java:31) at Org.codehaus.xfire.fault.SoapFaultSerializer.readMessage ( soapfaultserializer.java:28) at Org.codehaus.xfire.soap.handler.ReadHeadersHandler.checkForFault ( readheadershandler.java:111) at Org.codehaus.xfire.soap.handler.ReadHeadersHandler.invoke ( readheadershandler.java:67) at Org.codehaus.xfire.handler.HandlerPipeline.invoke (handlerpipeline.java:131) at Org.codehaus.xfire.client.Client.onReceive (client.java:406) at Org.codehaus.xfire.transport.http.HttpChannel.sendViaClient (httpchannel.java:139) at Org.codehaus.xfire.transport.http.HttpChannel.send (httpchannel.java:48) at Org.codehaus.xfire.handler.OutMessageSender.invoke (outmessagesender.java:26) at Org.codehaus.xfire.handler.HandlerPipeline.invoke (handlerpipeline.java:131) at Org.codehaus.xfire.client.Invocation.invoke (invocation.java:79) at Org.codehaus.xfire.client.Invocation.invoke (invocation.java:114) at Org.codehaus.xfire.client.Client.invoke ( client.java:336) at Org.codehaus.xfire.client.Client.invoke (client.java:368) at Com.zsy.jsec.zdsjyj.util.Main.main
 (main.java:35)


Description of the background code is wrong, as long as in the webserver annotation add targetnamespace can, please see the code:

@WebService public
class Helloworldimpl implements HelloWorld
{
    /**
     * TODO simply describes the implementation of the method (optional).
     * @see Com.zsy.server.helloworld#sayhello (java.lang.String)
     /
    @WebResult (name = "Name", targetnamespace = " http://server.zsy.com/")
    @WebMethod public
    String SayHello (@WebParam (name =" Name ", targetnamespace =" http:/ /server.zsy.com/") string string)
    {
        System.out.println (" Hello "+ String);
        Return "Hello," + string;
}
}


Add targetnamespace to the parameters and return values, targetnamespace do not write wrong, otherwise, the background can not get your parameter values, can not return to your value.

TargetNamespace this thing in the WSDL to replicate the most secure.


The results are as follows:


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.