我需要在我的项目中使用Web服务.我使用NetBeans,所以我右键单击我的项目并尝试添加一个新的"Web服务客户端".上次我检查时,这是创建Web服务客户端的方法.但它导致了一个AssertionError,说:
java.lang.AssertionError:org.xml.sax.SAXParseException; systemId:jar:file:/path/to/glassfish/modules/jaxb-osgi.jar!/com/sun/tools/xjc/reader/xmlschema/bindinfo/binding.xsd; lineNumber:52; columnNumber:88; schema_reference:无法读取模式文档" xjc.xsd ",因为由于accessExternalSchema属性设置的限制,不允许"文件"访问.
NetBeans的默认Java平台是JDK8(Oracle的正式版),因此当我更改我的netbeans.conf文件并将JDK7(也来自Oracle)作为我的默认版本时,一切正常.所以我认为问题出在JDK8上.这是我的java -version输出:
java版"1.8.0"
Java(TM)SE运行时环境(版本1.8.0-b132)
Java HotSpot(TM)64位服务器VM(版本25.0-b70,混合模式)
现在,我将JDK7作为我的默认Java平台.如果有办法使JDK8工作,请分享.
尝试创建一个C#客户端(将作为Windows服务开发),将SOAP请求发送到Web服务(并获取结果).
从这个问题我看到了这段代码:
protected virtual WebRequest CreateRequest(ISoapMessage soapMessage)
{
var wr = WebRequest.Create(soapMessage.Uri);
wr.ContentType = "text/xml;charset=utf-8";
wr.ContentLength = soapMessage.ContentXml.Length;
wr.Headers.Add("SOAPAction", soapMessage.SoapAction);
wr.Credentials = soapMessage.Credentials;
wr.Method = "POST";
wr.GetRequestStream().Write(Encoding.UTF8.GetBytes(soapMessage.ContentXml), 0, soapMessage.ContentXml.Length);
return wr;
}
public interface ISoapMessage
{
string Uri { get; }
string ContentXml { get; }
string SoapAction { get; }
ICredentials Credentials { get; }
}
Run Code Online (Sandbox Code Playgroud)
看起来不错,任何人都知道如何使用它,如果这是最好的做法?
我有第三方WSDL,我需要用Java编写代码,以便Web服务客户端调用第三方WSDL中的操作.现在,我使用Axis的WSDL2JAVA工具生成了客户端存根,并使用XMLbeans进行数据绑定.
wsimport在另一种选择.优缺点都有什么?我最初使用了一些基本的东西.现在我有这些选择
C:\axis2-1.5.1\bin>wsdl2java -uri mywsdlurl -o client -p somepackage -d xmlbeans -s -t -ssi
Run Code Online (Sandbox Code Playgroud) 我收到javax.net.ssl.SSLHandshakeException:当我尝试通过互联网进行Web服务的HTTPS发布时,握手异常期间远程主机关闭连接.但是相同的代码适用于其他Internet托管的Web服务.我尝试过很多东西,没有什么可以帮助我.我在这里发布了示例代码.有谁可以帮我解决这个问题?
public static void main(String[] args) throws Exception {
String xmlServerURL = "https://example.com/soap/WsRouter";
URL urlXMLServer = new URL(xmlServerURL);
// URLConnection supports HTTPS protocol only with JDK 1.4+
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(
"xxxx.example.com", 8083));
HttpURLConnection httpsURLConnection = (HttpURLConnection) urlXMLServer
.openConnection(proxy);
httpsURLConnection.setRequestProperty("Content-Type","text/xml; charset=utf-8");
//httpsURLConnection.setDoInput(true);
httpsURLConnection.setDoOutput(true);
httpsURLConnection.setConnectTimeout(300000);
//httpsURLConnection.setIgnoreProxy(false);
httpsURLConnection.setRequestMethod("POST");
//httpsURLConnection.setHostnameVerifier(DO_NOT_VERIFY);
// send request
PrintWriter out = new PrintWriter(
httpsURLConnection.getOutputStream());
StringBuffer requestXML = new StringBuffer();
requestXML.append(getProcessWorkOrderSOAPXML());
// get list of user
out.println(requestXML.toString());
out.close();
out.flush();
System.out.println("XML …Run Code Online (Sandbox Code Playgroud) 如何动态更改JAXWS客户端使用的地址?该客户端由wsimport生成.
我试图呼叫一个Web服务,但面临一个奇怪的行为.我们的服务器上运行了一个Web服务,但代码不对我们开放,因此无法看到墙后面发生了什么服务的所有者已经暴露了基于Web的测试客户端UI,它在文本框中输入并将显示对测试目的的响应.此输入框以下面提到的格式输入
<CONTENT>
<CONTENTID></CONTENTID>
<DOCUMENTID>DRI2</DOCUMENTID>
<LOCALECODE>en_US</LOCALECODE>
<LATEST_VERSION>false</LATEST_VERSION>
<INCREASEVIEWCOUNT>false</INCREASEVIEWCOUNT>
<ACTIVITY_TYPE></ACTIVITY_TYPE>
</CONTENT>
Run Code Online (Sandbox Code Playgroud)
它在这个用户界面上工作得很好,但是当我试图通过我的java代码调用这个Web服务时它连接以及获得服务授权但是当我试图调用上面的方法它给我以下错误消息
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXParseException: Content is not allowed in prolog.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206) …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用HttpDelete对象来调用Web服务的delete方法.Web服务的代码从消息的正文中解析JSON.但是,我无法理解如何向HttpDelete对象添加主体.有没有办法做到这一点?
使用HttpPut和HttpPost,我调用setEntity方法并传入我的JSON.HttpDelete似乎没有任何此类方法.
如果无法为HttpDelete对象设置主体,请将我链接到使用超类HttpDelete的资源,以便我可以设置方法(删除)并设置主体.我知道这不太理想,但此时我无法改变网络服务.
在为我公司购买的产品消费网络服务时,我遇到了一个奇怪的问题.该产品名为Campaign Commander,由一家名为Email Vision的公司制作.我们正在尝试使用"Data Mass Update SOAP API".
每当我尝试调用webservice上的任何方法时,调用实际上都会成功,但是客户端在处理响应时失败并且我得到一个异常.
错误的详细信息如下,感谢您提供的任何帮助.
当将服务作为Web引用使用时,我得到一个InvalidOperationException用于我所做的任何调用,并带有以下消息:
Client found response content type of 'multipart/related; type="application/xop+xml"; boundary="uuid:170e63fa-183c-4b18-9364-c62ca545a6e0"; start="<root.message@cxf.apache.org>"; start-info="text/xml"', but expected 'text/xml'.
The request failed with the error message:
--
--uuid:170e63fa-183c-4b18-9364-c62ca545a6e0
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
Content-Transfer-Encoding: binary
Content-ID: <root.message@cxf.apache.org>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:openApiConnectionResponse xmlns:ns2="http://api.service.apibatchmember.emailvision.com/" xmlns:ns3="http://exceptions.service.apibatchmember.emailvision.com/">
<return>DpKTe-9swUeOsxhHH9t-uLPeLyg-aa2xk3-aKe9oJ5S9Yymrnuf1FxYnzpaFojsQSkSCbJsZmrZ_d3v2-7Hj</return>
</ns2:openApiConnectionResponse>
</soap:Body>
</soap:Envelope>
--uuid:170e63fa-183c-4b18-9364-c62ca545a6e0--
--.
Run Code Online (Sandbox Code Playgroud)
如您所见,响应soap信封看起来有效(这是一个有效的响应并且调用成功),但客户端似乎遇到内容类型问题并生成异常.
当我将服务作为服务引用使用时,我得到一个ProtocolException用于我所做的任何调用,并带有以下消息:
The content type multipart/related; type="application/xop+xml"; boundary="uuid:af66440a-012e-4444-8814-895c843de5ec"; start="<root.message@cxf.apache.org>"; start-info="text/xml" of the response message does not match the content type …Run Code Online (Sandbox Code Playgroud) 仅出于教学目的,我想尝试使用免费的SOAP Web服务.
你想到了哪些?
隐含的业务并不重要/相关:只有易于访问(免费访问)和简单的服务合同.
欢迎任何指示!
由于WS客户端服务和端口的初始化需要很长时间,所以我喜欢在启动时初始化它们并重用相同的端口实例.初始化看起来像这样:
private static RequestContext requestContext = null;
static
{
MyService service = new MyService();
MyPort myPort = service.getMyServicePort();
Map<String, Object> requestContextMap = ((BindingProvider) myPort).getRequestContext();
requestContextMap = ((BindingProvider)myPort).getRequestContext();
requestContextMap.put(BindingProvider.USERNAME_PROPERTY, uName);
requestContextMap.put(BindingProvider.PASSWORD_PROPERTY, pWord);
rc = new RequestContext();
rc.setApplication("test");
rc.setUserId("test");
}
Run Code Online (Sandbox Code Playgroud)
我班上某个地方的电话:
myPort.someFunctionCall(requestContext, "someValue");
Run Code Online (Sandbox Code Playgroud)
我的问题:这个调用是否是线程安全的?
java ×5
jax-ws ×3
axis2 ×2
c# ×2
soap ×2
.net ×1
android ×1
axis ×1
http-delete ×1
httpclient ×1
java-8 ×1
netbeans-8 ×1
ssl ×1
wcf-client ×1
wsdl2java ×1