How do I call a remote web service method via the browser bar? | Java
Interface:
@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
public interface WsdlWebService {
@WebMethod
String getHelloString(String name);
}
Implementation:
@WebService(endpointInterface = "com.example.javaws.WsdlWebService")
public class WsdlWebServiceImpl implements WsdlWebService
{
@Override
public String getHelloString(String name) {
return "Hello, " + name + "!";
}
}
Call point:
public class WsdlWebServicePublisher
{
public static void main(String[] args)
{
Endpoint.publish("http://10.104.1.134:8888/autocomet/services/", new WsdlWebServiceImpl());
}
}
I wrote the following request, but nothing came up: http://10.104.1.134:8888/autocomet/services/WsdlWebServiceImplService/getHelloString?arg0=hello
Also here is the wsdl:
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://javaws.example.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://javaws.example.com/" name="WsdlWebServiceImplService">
<types/>
<message name="getHelloString">
<part name="arg0" type="xsd:string"/>
</message>
<message name="getHelloStringResponse">
<part name="return" type="xsd:string"/>
</message>
<portType name="WsdlWebService">
<operation name="getHelloString">
<input wsam:Action="http://javaws.example.com/WsdlWebService/getHelloStringRequest" message="tns:getHelloString"/>
<output wsam:Action="http://javaws.example.com/WsdlWebService/getHelloStringResponse" message="tns:getHelloStringResponse"/>
</operation>
</portType>
<binding name="WsdlWebServiceImplPortBinding" type="tns:WsdlWebService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<operation name="getHelloString">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://javaws.example.com/"/>
</input>
<output>
<soap:body use="literal" namespace="http://javaws.example.com/"/>
</output>
</operation>
</binding>
<service name="WsdlWebServiceImplService">
<port name="WsdlWebServiceImplPort" binding="tns:WsdlWebServiceImplPortBinding">
<soap:address location="http://10.104.1.134:8888/autocomet/services/"/>
</port>
</service>
</definitions>
0
2 answers
No way.
SOAP requires a POST request.
To call this method from the browser, use JavaScript.
0
Author: talex, 2019-10-11 08:55:59
What does the browser send to the address?
http://10.104.1.134:8888/autocomet/services/?wsdl
The client can be like this
public class WWSClient {
public static void main(String[] args) throws Exception {
URL url = new URL("http://10.104.1.134:8888/autocomet/services/?wsdl");
QName qname = new QName("http://javaws.example.com/", "WsdlWebServiceImplService");
Service service = Service.create(url, qname);
WsdlWebService wws = service.getPort(WsdlWebService.class);
System.out.println(wws.getHelloString("Строка"));
}
}
The browser can only make GET requests via a string You can, for example, add a servlet to the application that will pull the Web Service method
0
Author: zhhh, 2019-10-11 09:46:34