- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我已经获得了一个 .wsdl-URI 和一个 Java 示例(见下文)并且需要通过 SSL 进行 SOAP 调用并处理响应。我正在使用 PHP 和 Zend Framework,但不知道从哪里开始。我之前使用 C#.NET 调用过 SOAP 服务,但在通过向导配置服务后只需要 2-3 行代码。是否有一种简单的方法来进行此调用并处理生成的 XML?如果没有,我在哪里可以找到一个很好的例子来帮助我入门?
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPFault;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPHeader;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;
public class RegistryDetails {
private static final long serialVersionUID= 1L;
private static final String SERVICE = "https://ServiceProvider.com/TheService.pl";
private static final String TAG_GETPRODUCT = "getDetails";
private static String namespaceService = "http://ServiceProvider.com/TheService.xsd";
private static String namespaceUserSession = "http://ServiceProvider.com/UserSession.xsd";
private static String SYSTEM = "thesystem";
private static String USERNAME = "theusername";
private static String PASSWORD = "thepassword";
public static void main(String[] args) {
try {
//Create the connection
SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = soapConnFactory.createConnection();
//Create the actual message
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
MimeHeaders mimeHeader = message.getMimeHeaders();
mimeHeader.addHeader("SOAPAction", "");
//Create objects for the message parts
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPHeader header = envelope.getHeader();
SOAPElement userSession = header.addChildElement("UserSession", "UserSession", namespaceUserSession);
userSession.addChildElement("TypeOfService").addTextNode("Integrated");
userSession.addChildElement("System").addTextNode(SYSTEM);
userSession.addChildElement("Username").addTextNode(USERNAME);
userSession.addChildElement("Password").addTextNode(PASSWORD);
SOAPBody body = envelope.getBody();
//Populate the body
//Create the main element and namespace
SOAPElement getDetails = body.addChildElement(TAG_GETPRODUCT, "dfg", namespaceService);
getDetails.addChildElement("queryField1").addTextNode("xxx");
getDetails.addChildElement("queryField2").addTextNode("yyy");
getDetails.addChildElement("queryField3").addTextNode("zzz");
//Save the message
message.saveChanges();
//Check the input
System.out.println("\nREQUEST:\n");
message.writeTo(System.out);
System.out.println();
//Send the message and get a reply
//Send the message
SOAPMessage reply = connection.call(message, SERVICE);
System.out.println("\nRESPONSE:\n");
reply.writeTo(System.out);
System.out.println();
{
SOAPBody retbody = reply.getSOAPBody();
if (retbody.hasFault()) {
SOAPFault fault = retbody.getFault();
System.out.println("SOAPfault: " + fault.getFaultString());
}
else {
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
XPathExpression expr = xpath.compile("*/RESULT/HOV/ReturnField1");
String returnField1 = (String)expr.evaluate(retbody, XPathConstants.STRING);
System.out.println("Result: " + returnField1);
}
}
//Close the connection
connection.close();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
最佳答案
http://framework.zend.com/manual/en/zend.soap.client.html - 传入您的 WSDL URL,然后您可以根据需要进行调用。
关于php - 使用 Zend Framework 通过 SSL 进行 SOAP 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9720965/
嗨,我有一个包含此代码的 Zend 表单 $field = new Zend_Form_Element_Submit('submit'); $field->setAttrib('class', 'bt
我现在正在尝试使用 zend expressive 并研究如何处理数据库。我在看this ,但不清楚。我使用 composer 安装 zend-db,它提到在 dependencies.global.
我已经通过 Zend auth 创建了一个登录系统,这里是代码 // userAuthentication public function authAction(){ $reque
好的,所以我对 Zend 比较陌生。我已经创建了一个新的应用程序并开始构建基于 a guide 的身份验证系统.但是,服务器正在踢出一个内部服务器错误。 检查 PHP 错误日志后,我得到以下两个错误:
编辑:: 问题是由 Zend 路由引起的,请检查更新 我正在使用 xml 文件进行导航。 编辑::以下代码来自layout.phtml文件 $config = new Zend_Config_Xml(
我想将变量从 Controller 传递到表单。如何实现?谁能帮我解决这个问题。 谢谢。 最佳答案 只是一个活生生的例子: class Admin_Form_Product extends Admin
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
我使用默认 Zend_Rest_Route 来生成 Rest 路由: 所以鉴于我只是把 resources.router.routes.rest.type = Zend_Rest_Route在 app
是否存在类似于 Zend Validator Identical 的 Zend Filter? 我应该过滤 input=='test' 的情况 $el->addFilter('Identical','
在/application 文件夹中创建了几个文件夹(例如表单和模型),然后开始向这些文件夹添加类之后,如何使这些类的代码自动完成在我的各种其他文件(例如我的文件)中可用IndexController
我正在尝试删除隐藏表单元素上的默认装饰器。默认情况下,隐藏元素显示如下: Hidden Element Label (if I had set one) 我不希望隐藏元素占用页面上的空间。我想删除所
我是框架新手,但我在安装 zend 1.x 版本等方面没有任何困难。但是ZF2真的搞不懂......任何资源告诉我使用 zend 工具创建项目,即 bin 目录中的 zf.bat 或 zf.sh,但与
我想使用装饰器将下面的 Zend_Form 格式化为表格,在第一列中放置描述并 Zend_Form_Element_Radio 的选项在第二列中和 在每一行中添加 2 个选择,您可以在稍后的 html
当您查看 在下面的标记中,您会看到有一个带有 id 地址标签的 dt 和以下 dd,我想删除这些但保留 字段集。 要添加显示组,我在其中使用了这个 $this->addDisplayGroup(arr
我已经阅读了所有关于路由和 Zend 文档的帖子,但我仍然无法解决这个问题。 我有一个包含两个模块的多语言应用程序:default 和 admin。语言选择工作正常(在 Controller rout
/* Form Elements & Other Definitions Here ... */ $this->setAction("auth") ->setMethod("post")
我正在按照官方教程在 Zend 服务器上部署示例 Zend 应用程序。无论我部署什么,我唯一可以访问的是 hello world 页面(Hello world 打招呼)。 如何访问真实应用程序? ho
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 3年前关闭。 Improve thi
在 Zend 中使用命名空间的最佳实践是什么? 如何管理存储库、服务等的命名空间? 我在 Zend 文档 here 中找到了一个通用的目录结构,但它没有描述在哪里放置存储库和其他服务! 请将其视为 M
我有问题,以下 Zend 表单会引发错误。 问题是"file"元素和使用 setElementDecorators。 class Products_AddForm extends Zend_F
我是一名优秀的程序员,十分优秀!