C#如何调用axis2(使用了rampart,ws-policy)的java做的webservice
我用Java做的webservice,【tomcat+axis2+rampart模块+ws-policy】,
服务端是根据
Web Services Security with Apache Rampart Part 1 ( Transport Level Security )
做出来的
客户端用java可以调试通过
但是在.net中如何调用呢,应该如何做
[最优解释]
webservice 应该是和平台无关的。 用何种语言写又有什么关系。。。
[其他解释]
wsdl文件如下
<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://service.rampart.tutorial" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://service.rampart.tutorial">
<wsp:Policy xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UTOverTransport">
<wsp:ExactlyOne><wsp:All>
<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"><wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<sp:TransportToken><wsp:Policy>
<sp:HttpsToken RequireClientCertificate="false"/>
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Lax/>
</wsp:Policy>
</sp:Layout>
</wsp:Policy>
</sp:TransportBinding>
<sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"><wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"/>
</wsp:Policy>
</sp:SignedSupportingTokens>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.rampart.tutorial">
<xs:element name="add">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="a" type="xs:int"/>
<xs:element minOccurs="0" name="b" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="addResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="SumMtoN">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="x" type="xs:int"/>
<xs:element minOccurs="0" name="y" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="SumMtoNResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="addRequest">
<wsdl:part name="parameters" element="ns:add"/>
</wsdl:message>
<wsdl:message name="addResponse">
<wsdl:part name="parameters" element="ns:addResponse"/>
</wsdl:message>
<wsdl:message name="HelloWorldRequest"/>
<wsdl:message name="HelloWorldResponse"/>
<wsdl:message name="SumMtoNRequest">
<wsdl:part name="parameters" element="ns:SumMtoN"/>
</wsdl:message>
<wsdl:message name="SumMtoNResponse">
<wsdl:part name="parameters" element="ns:SumMtoNResponse"/>
</wsdl:message>
<wsdl:portType xmlns:wsp="http://www.w3.org/ns/ws-policy" name="WS_rampart3PortType" wsp:PolicyURIs="#UTOverTransport">
<wsdl:operation name="add">
<wsdl:input message="ns:addRequest" wsaw:Action="urn:add"/>
<wsdl:output message="ns:addResponse" wsaw:Action="urn:addResponse"/>
</wsdl:operation>
<wsdl:operation name="HelloWorld">
<wsdl:input message="ns:HelloWorldRequest" wsaw:Action="urn:HelloWorld"/>
<wsdl:output message="ns:HelloWorldResponse" wsaw:Action="urn:HelloWorldResponse"/>
</wsdl:operation>
<wsdl:operation name="SumMtoN">
<wsdl:input message="ns:SumMtoNRequest" wsaw:Action="urn:SumMtoN"/>
<wsdl:output message="ns:SumMtoNResponse" wsaw:Action="urn:SumMtoNResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WS_rampart3Soap11Binding" type="ns:WS_rampart3PortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="add">
<soap:operation soapAction="urn:add" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="HelloWorld">
<soap:operation soapAction="urn:HelloWorld" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="SumMtoN">
<soap:operation soapAction="urn:SumMtoN" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="WS_rampart3Soap12Binding" type="ns:WS_rampart3PortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="add">
<soap12:operation soapAction="urn:add" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="HelloWorld">
<soap12:operation soapAction="urn:HelloWorld" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="SumMtoN">
<soap12:operation soapAction="urn:SumMtoN" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="WS_rampart3HttpBinding" type="ns:WS_rampart3PortType">
<http:binding verb="POST"/>
<wsdl:operation name="add">
<http:operation location="add"/>
<wsdl:input>
<mime:content type="application/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="application/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="HelloWorld">
<http:operation location="HelloWorld"/>
<wsdl:input>
<mime:content type="application/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="application/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="SumMtoN">
<http:operation location="SumMtoN"/>
<wsdl:input>
<mime:content type="application/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="application/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WS_rampart3">
<wsdl:port name="WS_rampart3HttpSoap11Endpoint" binding="ns:WS_rampart3Soap11Binding">
<soap:address location="http://172.17.5.139/axis2/services/WS_rampart3.WS_rampart3HttpSoap11Endpoint/"/>
</wsdl:port>
<wsdl:port name="WS_rampart3HttpsSoap11Endpoint" binding="ns:WS_rampart3Soap11Binding">
<soap:address location="https://172.17.5.139/axis2/services/WS_rampart3.WS_rampart3HttpsSoap11Endpoint/"/>
</wsdl:port>
<wsdl:port name="WS_rampart3HttpsSoap12Endpoint" binding="ns:WS_rampart3Soap12Binding">
<soap12:address location="https://172.17.5.139/axis2/services/WS_rampart3.WS_rampart3HttpsSoap12Endpoint/"/>
</wsdl:port>
<wsdl:port name="WS_rampart3HttpSoap12Endpoint" binding="ns:WS_rampart3Soap12Binding">
<soap12:address location="http://172.17.5.139/axis2/services/WS_rampart3.WS_rampart3HttpSoap12Endpoint/"/>
</wsdl:port>
<wsdl:port name="WS_rampart3HttpsEndpoint" binding="ns:WS_rampart3HttpBinding">
<http:address location="https://172.17.5.139/axis2/services/WS_rampart3.WS_rampart3HttpsEndpoint/"/>
</wsdl:port>
<wsdl:port name="WS_rampart3HttpEndpoint" binding="ns:WS_rampart3HttpBinding">
<http:address location="http://172.17.5.139/axis2/services/WS_rampart3.WS_rampart3HttpEndpoint/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
[其他解释]
java访问代码
System.setProperty("javax.net.ssl.trustStore", "keys/.keystore");
System.setProperty("javax.net.ssl.trustStorePassword", "123456");
//To be able to load the client configuration from axis2.xml
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("rampart", null);
WS_rampart3Stub stub = new WS_rampart3Stub(ctx,"https://172.17.5.139:443/axis2/services/WS_rampart3");
ServiceClient sc = stub._getServiceClient();
sc.engageModule("rampart");
Options options = sc.getOptions();
options.setUserName("wang");
options.setPassword("xianshou");
int a = 14;
int b = 14;
int result = stub.add(a, b);
int x = 1;
int y = 1000;
int sumresult = stub.sumMtoN(x, y);
System.out.println(a + " + " + b + " = " + result);
System.out.println(x + " ~ " + y + " = " + sumresult);
[其他解释]
已经解决,过些时候请关注我的博客,谢谢
[其他解释]
楼主,不知道你的问题是怎么解决的,没看到你博客里有这方面的文章呀。
[其他解释]
怎么解决啊?